<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.4.0-alpha - src/lparser.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lparser.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.4.0-alpha</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">1013</td>
            <td class="headerCovTableEntry">1060</td>
            <td class="headerCovTableEntryHi">95.6 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:19</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lparser.c $
<span class="lineNum">       3 </span>            : ** Lua Parser
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : #define lparser_c
<span class="lineNum">       8 </span>            : #define LUA_CORE
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #include &quot;lprefix.h&quot;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &lt;limits.h&gt;
<span class="lineNum">      14 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      15 </span>            : 
<span class="lineNum">      16 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      17 </span>            : 
<span class="lineNum">      18 </span>            : #include &quot;lcode.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lfunc.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;llex.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;lmem.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      25 </span>            : #include &quot;lopcodes.h&quot;
<span class="lineNum">      26 </span>            : #include &quot;lparser.h&quot;
<span class="lineNum">      27 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      28 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      29 </span>            : #include &quot;ltable.h&quot;
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : /* maximum number of local variables per function (must be smaller
<span class="lineNum">      34 </span>            :    than 250, due to the bytecode format) */
<span class="lineNum">      35 </span>            : #define MAXVARS         200
<span class="lineNum">      36 </span>            : 
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : #define hasmultret(k)           ((k) == VCALL || (k) == VVARARG)
<span class="lineNum">      39 </span>            : 
<span class="lineNum">      40 </span>            : 
<span class="lineNum">      41 </span>            : /* because all strings are unified by the scanner, the parser
<span class="lineNum">      42 </span>            :    can use pointer equality for string equality */
<span class="lineNum">      43 </span>            : #define eqstr(a,b)      ((a) == (b))
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : /*
<span class="lineNum">      47 </span>            : ** nodes for block list (list of active blocks)
<span class="lineNum">      48 </span>            : */
<span class="lineNum">      49 </span>            : typedef struct BlockCnt {
<span class="lineNum">      50 </span>            :   struct BlockCnt *previous;  /* chain */
<span class="lineNum">      51 </span>            :   int firstlabel;  /* index of first label in this block */
<span class="lineNum">      52 </span>            :   int firstgoto;  /* index of first pending goto in this block */
<span class="lineNum">      53 </span>            :   lu_byte nactvar;  /* # active locals outside the block */
<span class="lineNum">      54 </span>            :   lu_byte upval;  /* true if some variable in the block is an upvalue */
<span class="lineNum">      55 </span>            :   lu_byte isloop;  /* true if 'block' is a loop */
<span class="lineNum">      56 </span>            :   lu_byte insidetbc;  /* true if inside the scope of a to-be-closed var. */
<span class="lineNum">      57 </span>            : } BlockCnt;
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span>            : 
<span class="lineNum">      61 </span>            : /*
<span class="lineNum">      62 </span>            : ** prototypes for recursive non-terminal functions
<span class="lineNum">      63 </span>            : */
<span class="lineNum">      64 </span>            : static void statement (LexState *ls);
<span class="lineNum">      65 </span>            : static void expr (LexState *ls, expdesc *v);
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            : 
<span class="lineNum">      68 </span><span class="lineCov">         12 : static l_noret error_expected (LexState *ls, int token) {</span>
<span class="lineNum">      69 </span><span class="lineCov">         12 :   luaX_syntaxerror(ls,</span>
<span class="lineNum">      70 </span><span class="lineCov">         12 :       luaO_pushfstring(ls-&gt;L, &quot;%s expected&quot;, luaX_token2str(ls, token)));</span>
<span class="lineNum">      71 </span>            : }
<span class="lineNum">      72 </span>            : 
<span class="lineNum">      73 </span>            : 
<span class="lineNum">      74 </span><span class="lineNoCov">          0 : static l_noret errorlimit (FuncState *fs, int limit, const char *what) {</span>
<span class="lineNum">      75 </span><span class="lineNoCov">          0 :   lua_State *L = fs-&gt;ls-&gt;L;</span>
<span class="lineNum">      76 </span>            :   const char *msg;
<span class="lineNum">      77 </span><span class="lineNoCov">          0 :   int line = fs-&gt;f-&gt;linedefined;</span>
<span class="lineNum">      78 </span><span class="lineNoCov">          0 :   const char *where = (line == 0)</span>
<span class="lineNum">      79 </span>            :                       ? &quot;main function&quot;
<span class="lineNum">      80 </span><span class="lineNoCov">          0 :                       : luaO_pushfstring(L, &quot;function at line %d&quot;, line);</span>
<span class="lineNum">      81 </span><span class="lineNoCov">          0 :   msg = luaO_pushfstring(L, &quot;too many %s (limit is %d) in %s&quot;,</span>
<span class="lineNum">      82 </span>            :                              what, limit, where);
<span class="lineNum">      83 </span><span class="lineNoCov">          0 :   luaX_syntaxerror(fs-&gt;ls, msg);</span>
<span class="lineNum">      84 </span>            : }
<span class="lineNum">      85 </span>            : 
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span><span class="lineCov">       9744 : static void checklimit (FuncState *fs, int v, int l, const char *what) {</span>
<span class="lineNum">      88 </span><span class="lineCov">       9744 :   if (v &gt; l) errorlimit(fs, l, what);</span>
<span class="lineNum">      89 </span><span class="lineCov">       9744 : }</span>
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            : /*
<span class="lineNum">      93 </span>            : ** Test whether next token is 'c'; if so, skip it.
<span class="lineNum">      94 </span>            : */
<span class="lineNum">      95 </span><span class="lineCov">      45579 : static int testnext (LexState *ls, int c) {</span>
<span class="lineNum">      96 </span><span class="lineCov">      45579 :   if (ls-&gt;t.token == c) {</span>
<span class="lineNum">      97 </span><span class="lineCov">      21980 :     luaX_next(ls);</span>
<span class="lineNum">      98 </span><span class="lineCov">      21980 :     return 1;</span>
<span class="lineNum">      99 </span>            :   }
<span class="lineNum">     100 </span><span class="lineCov">      23599 :   else return 0;</span>
<span class="lineNum">     101 </span>            : }
<span class="lineNum">     102 </span>            : 
<span class="lineNum">     103 </span>            : 
<span class="lineNum">     104 </span>            : /*
<span class="lineNum">     105 </span>            : ** Check that next token is 'c'.
<span class="lineNum">     106 </span>            : */
<span class="lineNum">     107 </span><span class="lineCov">      35439 : static void check (LexState *ls, int c) {</span>
<span class="lineNum">     108 </span><span class="lineCov">      35439 :   if (ls-&gt;t.token != c)</span>
<span class="lineNum">     109 </span><span class="lineCov">          3 :     error_expected(ls, c);</span>
<span class="lineNum">     110 </span><span class="lineCov">      35436 : }</span>
<span class="lineNum">     111 </span>            : 
<span class="lineNum">     112 </span>            : 
<span class="lineNum">     113 </span>            : /*
<span class="lineNum">     114 </span>            : ** Check that next token is 'c' and skip it.
<span class="lineNum">     115 </span>            : */
<span class="lineNum">     116 </span><span class="lineCov">       8364 : static void checknext (LexState *ls, int c) {</span>
<span class="lineNum">     117 </span><span class="lineCov">       8364 :   check(ls, c);</span>
<span class="lineNum">     118 </span><span class="lineCov">       8361 :   luaX_next(ls);</span>
<span class="lineNum">     119 </span><span class="lineCov">       8347 : }</span>
<span class="lineNum">     120 </span>            : 
<span class="lineNum">     121 </span>            : 
<span class="lineNum">     122 </span>            : #define check_condition(ls,c,msg)       { if (!(c)) luaX_syntaxerror(ls, msg); }
<span class="lineNum">     123 </span>            : 
<span class="lineNum">     124 </span>            : 
<span class="lineNum">     125 </span>            : /*
<span class="lineNum">     126 </span>            : ** Check that next token is 'what' and skip it. In case of error,
<span class="lineNum">     127 </span>            : ** raise an error that the expected 'what' should match a 'who'
<span class="lineNum">     128 </span>            : ** in line 'where' (if that is not the current line).
<span class="lineNum">     129 </span>            : */
<span class="lineNum">     130 </span><span class="lineCov">      11722 : static void check_match (LexState *ls, int what, int who, int where) {</span>
<span class="lineNum">     131 </span><span class="lineCov">      11722 :   if (unlikely(!testnext(ls, what))) {</span>
<span class="lineNum">     132 </span><span class="lineCov">          9 :     if (where == ls-&gt;linenumber)  /* all in the same line? */</span>
<span class="lineNum">     133 </span><span class="lineCov">          9 :       error_expected(ls, what);  /* do not need a complex message */</span>
<span class="lineNum">     134 </span>            :     else {
<span class="lineNum">     135 </span><span class="lineNoCov">          0 :       luaX_syntaxerror(ls, luaO_pushfstring(ls-&gt;L,</span>
<span class="lineNum">     136 </span>            :              &quot;%s expected (to close %s at line %d)&quot;,
<span class="lineNum">     137 </span>            :               luaX_token2str(ls, what), luaX_token2str(ls, who), where));
<span class="lineNum">     138 </span>            :     }
<span class="lineNum">     139 </span>            :   }
<span class="lineNum">     140 </span><span class="lineCov">      11713 : }</span>
<span class="lineNum">     141 </span>            : 
<span class="lineNum">     142 </span>            : 
<span class="lineNum">     143 </span><span class="lineCov">      26605 : static TString *str_checkname (LexState *ls) {</span>
<span class="lineNum">     144 </span>            :   TString *ts;
<span class="lineNum">     145 </span><span class="lineCov">      26605 :   check(ls, TK_NAME);</span>
<span class="lineNum">     146 </span><span class="lineCov">      26605 :   ts = ls-&gt;t.seminfo.ts;</span>
<span class="lineNum">     147 </span><span class="lineCov">      26605 :   luaX_next(ls);</span>
<span class="lineNum">     148 </span><span class="lineCov">      26605 :   return ts;</span>
<span class="lineNum">     149 </span>            : }
<span class="lineNum">     150 </span>            : 
<span class="lineNum">     151 </span>            : 
<span class="lineNum">     152 </span><span class="lineCov">      42051 : static void init_exp (expdesc *e, expkind k, int i) {</span>
<span class="lineNum">     153 </span><span class="lineCov">      42051 :   e-&gt;f = e-&gt;t = NO_JUMP;</span>
<span class="lineNum">     154 </span><span class="lineCov">      42051 :   e-&gt;k = k;</span>
<span class="lineNum">     155 </span><span class="lineCov">      42051 :   e-&gt;u.info = i;</span>
<span class="lineNum">     156 </span><span class="lineCov">      42051 : }</span>
<span class="lineNum">     157 </span>            : 
<span class="lineNum">     158 </span>            : 
<span class="lineNum">     159 </span><span class="lineCov">      22509 : static void init_var (expdesc *e, expkind k, int i) {</span>
<span class="lineNum">     160 </span><span class="lineCov">      22509 :   e-&gt;f = e-&gt;t = NO_JUMP;</span>
<span class="lineNum">     161 </span><span class="lineCov">      22509 :   e-&gt;k = k;</span>
<span class="lineNum">     162 </span><span class="lineCov">      22509 :   e-&gt;u.var.idx = i;</span>
<span class="lineNum">     163 </span><span class="lineCov">      22509 : }</span>
<span class="lineNum">     164 </span>            : 
<span class="lineNum">     165 </span>            : 
<span class="lineNum">     166 </span><span class="lineCov">      18059 : static void codestring (LexState *ls, expdesc *e, TString *s) {</span>
<span class="lineNum">     167 </span><span class="lineCov">      18059 :   init_exp(e, VK, luaK_stringK(ls-&gt;fs, s));</span>
<span class="lineNum">     168 </span><span class="lineCov">      18059 : }</span>
<span class="lineNum">     169 </span>            : 
<span class="lineNum">     170 </span>            : 
<span class="lineNum">     171 </span><span class="lineCov">       2812 : static void codename (LexState *ls, expdesc *e) {</span>
<span class="lineNum">     172 </span><span class="lineCov">       2812 :   codestring(ls, e, str_checkname(ls));</span>
<span class="lineNum">     173 </span><span class="lineCov">       2812 : }</span>
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span>            : 
<span class="lineNum">     176 </span>            : /*
<span class="lineNum">     177 </span>            : ** Register a new local variable in the active 'Proto' (for debug
<span class="lineNum">     178 </span>            : ** information).
<span class="lineNum">     179 </span>            : */
<span class="lineNum">     180 </span><span class="lineCov">       5362 : static int registerlocalvar (LexState *ls, TString *varname) {</span>
<span class="lineNum">     181 </span><span class="lineCov">       5362 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     182 </span><span class="lineCov">       5362 :   Proto *f = fs-&gt;f;</span>
<span class="lineNum">     183 </span><span class="lineCov">       5362 :   int oldsize = f-&gt;sizelocvars;</span>
<span class="lineNum">     184 </span><span class="lineCov">       5362 :   luaM_growvector(ls-&gt;L, f-&gt;locvars, fs-&gt;nlocvars, f-&gt;sizelocvars,</span>
<span class="lineNum">     185 </span>            :                   LocVar, SHRT_MAX, &quot;local variables&quot;);
<span class="lineNum">     186 </span><span class="lineCov">      14114 :   while (oldsize &lt; f-&gt;sizelocvars)</span>
<span class="lineNum">     187 </span><span class="lineCov">       8752 :     f-&gt;locvars[oldsize++].varname = NULL;</span>
<span class="lineNum">     188 </span><span class="lineCov">       5362 :   f-&gt;locvars[fs-&gt;nlocvars].varname = varname;</span>
<span class="lineNum">     189 </span><span class="lineCov">       5362 :   luaC_objbarrier(ls-&gt;L, f, varname);</span>
<span class="lineNum">     190 </span><span class="lineCov">       5362 :   return fs-&gt;nlocvars++;</span>
<span class="lineNum">     191 </span>            : }
<span class="lineNum">     192 </span>            : 
<span class="lineNum">     193 </span>            : 
<span class="lineNum">     194 </span>            : /*
<span class="lineNum">     195 </span>            : ** Create a new local variable with the given 'name'.
<span class="lineNum">     196 </span>            : */
<span class="lineNum">     197 </span><span class="lineCov">       5362 : static Vardesc *new_localvar (LexState *ls, TString *name) {</span>
<span class="lineNum">     198 </span><span class="lineCov">       5362 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     199 </span><span class="lineCov">       5362 :   Dyndata *dyd = ls-&gt;dyd;</span>
<span class="lineNum">     200 </span>            :   Vardesc *var;
<span class="lineNum">     201 </span><span class="lineCov">       5362 :   int reg = registerlocalvar(ls, name);</span>
<span class="lineNum">     202 </span><span class="lineCov">       5362 :   checklimit(fs, dyd-&gt;actvar.n + 1 - fs-&gt;firstlocal,</span>
<span class="lineNum">     203 </span>            :                   MAXVARS, &quot;local variables&quot;);
<span class="lineNum">     204 </span><span class="lineCov">       5362 :   luaM_growvector(ls-&gt;L, dyd-&gt;actvar.arr, dyd-&gt;actvar.n + 1,</span>
<span class="lineNum">     205 </span>            :                   dyd-&gt;actvar.size, Vardesc, MAX_INT, &quot;local variables&quot;);
<span class="lineNum">     206 </span><span class="lineCov">       5362 :   var = &amp;dyd-&gt;actvar.arr[dyd-&gt;actvar.n++];</span>
<span class="lineNum">     207 </span><span class="lineCov">       5362 :   var-&gt;idx = cast(short, reg);</span>
<span class="lineNum">     208 </span><span class="lineCov">       5362 :   var-&gt;name = name;</span>
<span class="lineNum">     209 </span><span class="lineCov">       5362 :   var-&gt;ro = 0;</span>
<span class="lineNum">     210 </span><span class="lineCov">       5362 :   return var;</span>
<span class="lineNum">     211 </span>            : }
<span class="lineNum">     212 </span>            : 
<span class="lineNum">     213 </span>            : #define new_localvarliteral(ls,v) \
<span class="lineNum">     214 </span>            :     new_localvar(ls, luaX_newstring(ls, &quot;&quot; v, (sizeof(v)/sizeof(char)) - 1));
<span class="lineNum">     215 </span>            : 
<span class="lineNum">     216 </span>            : 
<span class="lineNum">     217 </span>            : 
<span class="lineNum">     218 </span>            : /*
<span class="lineNum">     219 </span>            : ** Return the &quot;variable description&quot; (Vardesc) of a given
<span class="lineNum">     220 </span>            : ** variable
<span class="lineNum">     221 </span>            : */
<span class="lineNum">     222 </span><span class="lineCov">     179439 : static Vardesc *getlocalvardesc (FuncState *fs, int i) {</span>
<span class="lineNum">     223 </span><span class="lineCov">     179439 :   return &amp;fs-&gt;ls-&gt;dyd-&gt;actvar.arr[fs-&gt;firstlocal + i];</span>
<span class="lineNum">     224 </span>            : }
<span class="lineNum">     225 </span>            : 
<span class="lineNum">     226 </span>            : /*
<span class="lineNum">     227 </span>            : ** Get the debug-information entry for current variable 'i'.
<span class="lineNum">     228 </span>            : */
<span class="lineNum">     229 </span><span class="lineCov">     178410 : static LocVar *getlocvar (FuncState *fs, int i) {</span>
<span class="lineNum">     230 </span><span class="lineCov">     178410 :   int idx = getlocalvardesc(fs, i)-&gt;idx;</span>
<span class="lineNum">     231 </span>            :   lua_assert(idx &lt; fs-&gt;nlocvars);
<span class="lineNum">     232 </span><span class="lineCov">     178410 :   return &amp;fs-&gt;f-&gt;locvars[idx];</span>
<span class="lineNum">     233 </span>            : }
<span class="lineNum">     234 </span>            : 
<span class="lineNum">     235 </span>            : 
<span class="lineNum">     236 </span>            : /*
<span class="lineNum">     237 </span>            : ** Return the &quot;variable description&quot; (Vardesc) of a given
<span class="lineNum">     238 </span>            : ** variable or upvalue
<span class="lineNum">     239 </span>            : */
<span class="lineNum">     240 </span><span class="lineCov">       1543 : static Vardesc *getvardesc (FuncState *fs, expdesc *e) {</span>
<span class="lineNum">     241 </span><span class="lineCov">       1543 :   if (e-&gt;k == VLOCAL)</span>
<span class="lineNum">     242 </span><span class="lineCov">        795 :     return getlocalvardesc(fs, e-&gt;u.var.idx);</span>
<span class="lineNum">     243 </span><span class="lineCov">        748 :   else if (e-&gt;k != VUPVAL)</span>
<span class="lineNum">     244 </span><span class="lineCov">        513 :     return NULL;  /* not a local variable */</span>
<span class="lineNum">     245 </span>            :   else {  /* upvalue: must go up all levels up to the original local */
<span class="lineNum">     246 </span><span class="lineCov">        235 :     int idx = e-&gt;u.var.idx;</span>
<span class="lineNum">     247 </span><span class="lineNoCov">          0 :     for (;;) {</span>
<span class="lineNum">     248 </span><span class="lineCov">        235 :       Upvaldesc *up = &amp;fs-&gt;f-&gt;upvalues[idx];</span>
<span class="lineNum">     249 </span><span class="lineCov">        235 :       fs = fs-&gt;prev;  /* must look at the previous level */</span>
<span class="lineNum">     250 </span><span class="lineCov">        235 :       idx = up-&gt;idx;  /* at this index */</span>
<span class="lineNum">     251 </span><span class="lineCov">        235 :       if (fs == NULL) {  /* no more levels? (can happen only with _ENV) */</span>
<span class="lineNum">     252 </span>            :         lua_assert(strcmp(getstr(up-&gt;name), LUA_ENV) == 0);
<span class="lineNum">     253 </span><span class="lineCov">          1 :         return NULL;</span>
<span class="lineNum">     254 </span>            :       }
<span class="lineNum">     255 </span><span class="lineCov">        234 :       else if (up-&gt;instack)  /* got to the original level? */</span>
<span class="lineNum">     256 </span><span class="lineCov">        234 :         return getlocalvardesc(fs, idx);</span>
<span class="lineNum">     257 </span>            :       /* else repeat for previous level */
<span class="lineNum">     258 </span>            :     }
<span class="lineNum">     259 </span>            :   }
<span class="lineNum">     260 </span>            : }
<span class="lineNum">     261 </span>            : 
<span class="lineNum">     262 </span>            : 
<span class="lineNum">     263 </span><span class="lineCov">       1543 : static void check_readonly (LexState *ls, expdesc *e) {</span>
<span class="lineNum">     264 </span><span class="lineCov">       1543 :   Vardesc *vardesc = getvardesc(ls-&gt;fs, e);</span>
<span class="lineNum">     265 </span><span class="lineCov">       1543 :   if (vardesc &amp;&amp; vardesc-&gt;ro) {  /* is variable local and const? */</span>
<span class="lineNum">     266 </span><span class="lineCov">          2 :     const char *msg = luaO_pushfstring(ls-&gt;L,</span>
<span class="lineNum">     267 </span><span class="lineCov">          2 :        &quot;attempt to assign to const variable '%s'&quot;, getstr(vardesc-&gt;name));</span>
<span class="lineNum">     268 </span><span class="lineCov">          2 :     luaK_semerror(ls, msg);  /* error */</span>
<span class="lineNum">     269 </span>            :   }
<span class="lineNum">     270 </span><span class="lineCov">       1541 : }</span>
<span class="lineNum">     271 </span>            : 
<span class="lineNum">     272 </span>            : 
<span class="lineNum">     273 </span>            : /*
<span class="lineNum">     274 </span>            : ** Start the scope for the last 'nvars' created variables.
<span class="lineNum">     275 </span>            : ** (debug info.)
<span class="lineNum">     276 </span>            : */
<span class="lineNum">     277 </span><span class="lineCov">       4205 : static void adjustlocalvars (LexState *ls, int nvars) {</span>
<span class="lineNum">     278 </span><span class="lineCov">       4205 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     279 </span><span class="lineCov">       4205 :   fs-&gt;nactvar = cast_byte(fs-&gt;nactvar + nvars);</span>
<span class="lineNum">     280 </span><span class="lineCov">       9565 :   for (; nvars; nvars--) {</span>
<span class="lineNum">     281 </span><span class="lineCov">       5360 :     getlocvar(fs, fs-&gt;nactvar - nvars)-&gt;startpc = fs-&gt;pc;</span>
<span class="lineNum">     282 </span>            :   }
<span class="lineNum">     283 </span><span class="lineCov">       4205 : }</span>
<span class="lineNum">     284 </span>            : 
<span class="lineNum">     285 </span>            : 
<span class="lineNum">     286 </span>            : /*
<span class="lineNum">     287 </span>            : ** Close the scope for all variables up to level 'tolevel'.
<span class="lineNum">     288 </span>            : ** (debug info.)
<span class="lineNum">     289 </span>            : */
<span class="lineNum">     290 </span><span class="lineCov">       5065 : static void removevars (FuncState *fs, int tolevel) {</span>
<span class="lineNum">     291 </span><span class="lineCov">       5065 :   fs-&gt;ls-&gt;dyd-&gt;actvar.n -= (fs-&gt;nactvar - tolevel);</span>
<span class="lineNum">     292 </span><span class="lineCov">      10415 :   while (fs-&gt;nactvar &gt; tolevel)</span>
<span class="lineNum">     293 </span><span class="lineCov">       5350 :     getlocvar(fs, --fs-&gt;nactvar)-&gt;endpc = fs-&gt;pc;</span>
<span class="lineNum">     294 </span><span class="lineCov">       5065 : }</span>
<span class="lineNum">     295 </span>            : 
<span class="lineNum">     296 </span>            : 
<span class="lineNum">     297 </span>            : /*
<span class="lineNum">     298 </span>            : ** Search the upvalues of the function 'fs' for one
<span class="lineNum">     299 </span>            : ** with the given 'name'.
<span class="lineNum">     300 </span>            : */
<span class="lineNum">     301 </span><span class="lineCov">      21626 : static int searchupvalue (FuncState *fs, TString *name) {</span>
<span class="lineNum">     302 </span>            :   int i;
<span class="lineNum">     303 </span><span class="lineCov">      21626 :   Upvaldesc *up = fs-&gt;f-&gt;upvalues;</span>
<span class="lineNum">     304 </span><span class="lineCov">      35287 :   for (i = 0; i &lt; fs-&gt;nups; i++) {</span>
<span class="lineNum">     305 </span><span class="lineCov">      22452 :     if (eqstr(up[i].name, name)) return i;</span>
<span class="lineNum">     306 </span>            :   }
<span class="lineNum">     307 </span><span class="lineCov">      12835 :   return -1;  /* not found */</span>
<span class="lineNum">     308 </span>            : }
<span class="lineNum">     309 </span>            : 
<span class="lineNum">     310 </span>            : 
<span class="lineNum">     311 </span><span class="lineCov">       3068 : static int newupvalue (FuncState *fs, TString *name, expdesc *v) {</span>
<span class="lineNum">     312 </span><span class="lineCov">       3068 :   Proto *f = fs-&gt;f;</span>
<span class="lineNum">     313 </span><span class="lineCov">       3068 :   int oldsize = f-&gt;sizeupvalues;</span>
<span class="lineNum">     314 </span><span class="lineCov">       3068 :   checklimit(fs, fs-&gt;nups + 1, MAXUPVAL, &quot;upvalues&quot;);</span>
<span class="lineNum">     315 </span><span class="lineCov">       3068 :   luaM_growvector(fs-&gt;ls-&gt;L, f-&gt;upvalues, fs-&gt;nups, f-&gt;sizeupvalues,</span>
<span class="lineNum">     316 </span>            :                   Upvaldesc, MAXUPVAL, &quot;upvalues&quot;);
<span class="lineNum">     317 </span><span class="lineCov">      10308 :   while (oldsize &lt; f-&gt;sizeupvalues)</span>
<span class="lineNum">     318 </span><span class="lineCov">       7240 :     f-&gt;upvalues[oldsize++].name = NULL;</span>
<span class="lineNum">     319 </span><span class="lineCov">       3068 :   f-&gt;upvalues[fs-&gt;nups].instack = (v-&gt;k == VLOCAL);</span>
<span class="lineNum">     320 </span><span class="lineCov">       3068 :   f-&gt;upvalues[fs-&gt;nups].idx = cast_byte(v-&gt;u.var.idx);</span>
<span class="lineNum">     321 </span><span class="lineCov">       3068 :   f-&gt;upvalues[fs-&gt;nups].name = name;</span>
<span class="lineNum">     322 </span><span class="lineCov">       3068 :   luaC_objbarrier(fs-&gt;ls-&gt;L, f, name);</span>
<span class="lineNum">     323 </span><span class="lineCov">       3068 :   return fs-&gt;nups++;</span>
<span class="lineNum">     324 </span>            : }
<span class="lineNum">     325 </span>            : 
<span class="lineNum">     326 </span>            : 
<span class="lineNum">     327 </span>            : /*
<span class="lineNum">     328 </span>            : ** Look for an active local variable with the name 'n' in the
<span class="lineNum">     329 </span>            : ** function 'fs'.
<span class="lineNum">     330 </span>            : */
<span class="lineNum">     331 </span><span class="lineCov">      32276 : static int searchvar (FuncState *fs, TString *n) {</span>
<span class="lineNum">     332 </span>            :   int i;
<span class="lineNum">     333 </span><span class="lineCov">     189230 :   for (i = cast_int(fs-&gt;nactvar) - 1; i &gt;= 0; i--) {</span>
<span class="lineNum">     334 </span><span class="lineCov">     167604 :     if (eqstr(n, getlocvar(fs, i)-&gt;varname))</span>
<span class="lineNum">     335 </span><span class="lineCov">      10650 :       return i;</span>
<span class="lineNum">     336 </span>            :   }
<span class="lineNum">     337 </span><span class="lineCov">      21626 :   return -1;  /* not found */</span>
<span class="lineNum">     338 </span>            : }
<span class="lineNum">     339 </span>            : 
<span class="lineNum">     340 </span>            : 
<span class="lineNum">     341 </span>            : /*
<span class="lineNum">     342 </span>            : ** Mark block where variable at given level was defined
<span class="lineNum">     343 </span>            : ** (to emit close instructions later).
<span class="lineNum">     344 </span>            : */
<span class="lineNum">     345 </span><span class="lineCov">       1712 : static void markupval (FuncState *fs, int level) {</span>
<span class="lineNum">     346 </span><span class="lineCov">       1712 :   BlockCnt *bl = fs-&gt;bl;</span>
<span class="lineNum">     347 </span><span class="lineCov">       1740 :   while (bl-&gt;nactvar &gt; level)</span>
<span class="lineNum">     348 </span><span class="lineCov">         28 :     bl = bl-&gt;previous;</span>
<span class="lineNum">     349 </span><span class="lineCov">       1712 :   bl-&gt;upval = 1;</span>
<span class="lineNum">     350 </span><span class="lineCov">       1712 :   fs-&gt;needclose = 1;</span>
<span class="lineNum">     351 </span><span class="lineCov">       1712 : }</span>
<span class="lineNum">     352 </span>            : 
<span class="lineNum">     353 </span>            : 
<span class="lineNum">     354 </span>            : /*
<span class="lineNum">     355 </span>            : ** Find a variable with the given name 'n'. If it is an upvalue, add
<span class="lineNum">     356 </span>            : ** this upvalue into all intermediate functions. If it is a global, set
<span class="lineNum">     357 </span>            : ** 'var' as 'void' as a flag.
<span class="lineNum">     358 </span>            : */
<span class="lineNum">     359 </span><span class="lineCov">      40490 : static void singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) {</span>
<span class="lineNum">     360 </span><span class="lineCov">      40490 :   if (fs == NULL)  /* no more levels? */</span>
<span class="lineNum">     361 </span><span class="lineCov">       8214 :     init_exp(var, VVOID, 0);  /* default is global */</span>
<span class="lineNum">     362 </span>            :   else {
<span class="lineNum">     363 </span><span class="lineCov">      32276 :     int v = searchvar(fs, n);  /* look up locals at current level */</span>
<span class="lineNum">     364 </span><span class="lineCov">      32276 :     if (v &gt;= 0) {  /* found? */</span>
<span class="lineNum">     365 </span><span class="lineCov">      10650 :       init_var(var, VLOCAL, v);  /* variable is local */</span>
<span class="lineNum">     366 </span><span class="lineCov">      10650 :       if (!base)</span>
<span class="lineNum">     367 </span><span class="lineCov">       1666 :         markupval(fs, v);  /* local will be used as an upval */</span>
<span class="lineNum">     368 </span>            :     }
<span class="lineNum">     369 </span>            :     else {  /* not found as local at current level; try upvalues */
<span class="lineNum">     370 </span><span class="lineCov">      21626 :       int idx = searchupvalue(fs, n);  /* try existing upvalues */</span>
<span class="lineNum">     371 </span><span class="lineCov">      21626 :       if (idx &lt; 0) {  /* not found? */</span>
<span class="lineNum">     372 </span><span class="lineCov">      12835 :         singlevaraux(fs-&gt;prev, n, var, 0);  /* try upper levels */</span>
<span class="lineNum">     373 </span><span class="lineCov">      12835 :         if (var-&gt;k == VVOID)  /* not found? */</span>
<span class="lineNum">     374 </span><span class="lineCov">      10280 :           return;  /* it is a global */</span>
<span class="lineNum">     375 </span>            :         /* else was LOCAL or UPVAL */
<span class="lineNum">     376 </span><span class="lineCov">       2555 :         idx  = newupvalue(fs, n, var);  /* will be a new upvalue */</span>
<span class="lineNum">     377 </span>            :       }
<span class="lineNum">     378 </span><span class="lineCov">      11346 :       init_var(var, VUPVAL, idx);  /* new or old upvalue */</span>
<span class="lineNum">     379 </span>            :     }
<span class="lineNum">     380 </span>            :   }
<span class="lineNum">     381 </span>            : }
<span class="lineNum">     382 </span>            : 
<span class="lineNum">     383 </span>            : 
<span class="lineNum">     384 </span>            : /*
<span class="lineNum">     385 </span>            : ** Find a variable with the given name 'n', handling global variables
<span class="lineNum">     386 </span>            : ** too.
<span class="lineNum">     387 </span>            : */
<span class="lineNum">     388 </span><span class="lineCov">      19441 : static void singlevar (LexState *ls, expdesc *var) {</span>
<span class="lineNum">     389 </span><span class="lineCov">      19441 :   TString *varname = str_checkname(ls);</span>
<span class="lineNum">     390 </span><span class="lineCov">      19441 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     391 </span><span class="lineCov">      19441 :   singlevaraux(fs, varname, var, 1);</span>
<span class="lineNum">     392 </span><span class="lineCov">      19441 :   if (var-&gt;k == VVOID) {  /* global name? */</span>
<span class="lineNum">     393 </span>            :     expdesc key;
<span class="lineNum">     394 </span><span class="lineCov">       8214 :     singlevaraux(fs, ls-&gt;envn, var, 1);  /* get environment variable */</span>
<span class="lineNum">     395 </span>            :     lua_assert(var-&gt;k != VVOID);  /* this one must exist */
<span class="lineNum">     396 </span><span class="lineCov">       8214 :     codestring(ls, &amp;key, varname);  /* key is variable name */</span>
<span class="lineNum">     397 </span><span class="lineCov">       8214 :     luaK_indexed(fs, var, &amp;key);  /* env[varname] */</span>
<span class="lineNum">     398 </span>            :   }
<span class="lineNum">     399 </span><span class="lineCov">      19441 : }</span>
<span class="lineNum">     400 </span>            : 
<span class="lineNum">     401 </span>            : 
<span class="lineNum">     402 </span>            : /*
<span class="lineNum">     403 </span>            : ** Adjust the number of results from an expression list 'e' with 'nexps'
<span class="lineNum">     404 </span>            : ** expressions to 'nvars' values.
<span class="lineNum">     405 </span>            : */
<span class="lineNum">     406 </span><span class="lineCov">       2000 : static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {</span>
<span class="lineNum">     407 </span><span class="lineCov">       2000 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     408 </span><span class="lineCov">       2000 :   int needed = nvars - nexps;  /* extra values needed */</span>
<span class="lineNum">     409 </span><span class="lineCov">       2515 :   if (hasmultret(e-&gt;k)) {  /* last expression has multiple returns? */</span>
<span class="lineNum">     410 </span><span class="lineCov">        515 :     int extra = needed + 1;  /* discount last expression itself */</span>
<span class="lineNum">     411 </span><span class="lineCov">        515 :     if (extra &lt; 0)</span>
<span class="lineNum">     412 </span><span class="lineNoCov">          0 :       extra = 0;</span>
<span class="lineNum">     413 </span><span class="lineCov">        515 :     luaK_setreturns(fs, e, extra);  /* last exp. provides the difference */</span>
<span class="lineNum">     414 </span>            :   }
<span class="lineNum">     415 </span>            :   else {
<span class="lineNum">     416 </span><span class="lineCov">       1485 :     if (e-&gt;k != VVOID)  /* at least one expression? */</span>
<span class="lineNum">     417 </span><span class="lineCov">       1426 :       luaK_exp2nextreg(fs, e);  /* close last expression */</span>
<span class="lineNum">     418 </span><span class="lineCov">       1485 :     if (needed &gt; 0)  /* missing values? */</span>
<span class="lineNum">     419 </span><span class="lineCov">         63 :       luaK_nil(fs, fs-&gt;freereg, needed);  /* complete with nils */</span>
<span class="lineNum">     420 </span>            :   }
<span class="lineNum">     421 </span><span class="lineCov">       2000 :   if (needed &gt; 0)</span>
<span class="lineNum">     422 </span><span class="lineCov">        361 :     luaK_reserveregs(fs, needed);  /* registers for extra values */</span>
<span class="lineNum">     423 </span>            :   else  /* adding 'needed' is actually a subtraction */
<span class="lineNum">     424 </span><span class="lineCov">       1639 :     fs-&gt;freereg += needed;  /* remove extra values */</span>
<span class="lineNum">     425 </span><span class="lineCov">       2000 : }</span>
<span class="lineNum">     426 </span>            : 
<span class="lineNum">     427 </span>            : 
<span class="lineNum">     428 </span>            : /*
<span class="lineNum">     429 </span>            : ** Macros to limit the maximum recursion depth while parsing
<span class="lineNum">     430 </span>            : */
<span class="lineNum">     431 </span>            : #define enterlevel(ls)  luaE_enterCcall((ls)-&gt;L)
<span class="lineNum">     432 </span>            : 
<span class="lineNum">     433 </span>            : #define leavelevel(ls)  luaE_exitCcall((ls)-&gt;L)
<span class="lineNum">     434 </span>            : 
<span class="lineNum">     435 </span>            : 
<span class="lineNum">     436 </span>            : /*
<span class="lineNum">     437 </span>            : ** Generates an error that a goto jumps into the scope of some
<span class="lineNum">     438 </span>            : ** local variable.
<span class="lineNum">     439 </span>            : */
<span class="lineNum">     440 </span><span class="lineCov">          1 : static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {</span>
<span class="lineNum">     441 </span><span class="lineCov">          1 :   const char *varname = getstr(getlocvar(ls-&gt;fs, gt-&gt;nactvar)-&gt;varname);</span>
<span class="lineNum">     442 </span><span class="lineCov">          1 :   const char *msg = &quot;&lt;goto %s&gt; at line %d jumps into the scope of local '%s'&quot;;</span>
<span class="lineNum">     443 </span><span class="lineCov">          1 :   msg = luaO_pushfstring(ls-&gt;L, msg, getstr(gt-&gt;name), gt-&gt;line, varname);</span>
<span class="lineNum">     444 </span><span class="lineCov">          1 :   luaK_semerror(ls, msg);  /* raise the error */</span>
<span class="lineNum">     445 </span>            : }
<span class="lineNum">     446 </span>            : 
<span class="lineNum">     447 </span>            : 
<span class="lineNum">     448 </span>            : /*
<span class="lineNum">     449 </span>            : ** Solves the goto at index 'g' to given 'label' and removes it
<span class="lineNum">     450 </span>            : ** from the list of pending goto's.
<span class="lineNum">     451 </span>            : ** If it jumps into the scope of some variable, raises an error.
<span class="lineNum">     452 </span>            : */
<span class="lineNum">     453 </span><span class="lineCov">         16 : static void solvegoto (LexState *ls, int g, Labeldesc *label) {</span>
<span class="lineNum">     454 </span>            :   int i;
<span class="lineNum">     455 </span><span class="lineCov">         16 :   Labellist *gl = &amp;ls-&gt;dyd-&gt;gt;  /* list of goto's */</span>
<span class="lineNum">     456 </span><span class="lineCov">         16 :   Labeldesc *gt = &amp;gl-&gt;arr[g];  /* goto to be resolved */</span>
<span class="lineNum">     457 </span>            :   lua_assert(eqstr(gt-&gt;name, label-&gt;name));
<span class="lineNum">     458 </span><span class="lineCov">         16 :   if (unlikely(gt-&gt;nactvar &lt; label-&gt;nactvar))  /* enter some scope? */</span>
<span class="lineNum">     459 </span><span class="lineCov">          1 :     jumpscopeerror(ls, gt);</span>
<span class="lineNum">     460 </span><span class="lineCov">         15 :   luaK_patchlist(ls-&gt;fs, gt-&gt;pc, label-&gt;pc);</span>
<span class="lineNum">     461 </span><span class="lineCov">         15 :   for (i = g; i &lt; gl-&gt;n - 1; i++)  /* remove goto from pending list */</span>
<span class="lineNum">     462 </span><span class="lineNoCov">          0 :     gl-&gt;arr[i] = gl-&gt;arr[i + 1];</span>
<span class="lineNum">     463 </span><span class="lineCov">         15 :   gl-&gt;n--;</span>
<span class="lineNum">     464 </span><span class="lineCov">         15 : }</span>
<span class="lineNum">     465 </span>            : 
<span class="lineNum">     466 </span>            : 
<span class="lineNum">     467 </span>            : /*
<span class="lineNum">     468 </span>            : ** Search for an active label with the given name.
<span class="lineNum">     469 </span>            : */
<span class="lineNum">     470 </span><span class="lineCov">         13 : static Labeldesc *findlabel (LexState *ls, TString *name) {</span>
<span class="lineNum">     471 </span>            :   int i;
<span class="lineNum">     472 </span><span class="lineCov">         13 :   Dyndata *dyd = ls-&gt;dyd;</span>
<span class="lineNum">     473 </span>            :   /* check labels in current function for a match */
<span class="lineNum">     474 </span><span class="lineCov">         22 :   for (i = ls-&gt;fs-&gt;firstlabel; i &lt; dyd-&gt;label.n; i++) {</span>
<span class="lineNum">     475 </span><span class="lineCov">         11 :     Labeldesc *lb = &amp;dyd-&gt;label.arr[i];</span>
<span class="lineNum">     476 </span><span class="lineCov">         11 :     if (eqstr(lb-&gt;name, name))  /* correct label? */</span>
<span class="lineNum">     477 </span><span class="lineCov">          2 :       return lb;</span>
<span class="lineNum">     478 </span>            :   }
<span class="lineNum">     479 </span><span class="lineCov">         11 :   return NULL;  /* label not found */</span>
<span class="lineNum">     480 </span>            : }
<span class="lineNum">     481 </span>            : 
<span class="lineNum">     482 </span>            : 
<span class="lineNum">     483 </span>            : /*
<span class="lineNum">     484 </span>            : ** Adds a new label/goto in the corresponding list.
<span class="lineNum">     485 </span>            : */
<span class="lineNum">     486 </span><span class="lineCov">        366 : static int newlabelentry (LexState *ls, Labellist *l, TString *name,</span>
<span class="lineNum">     487 </span>            :                           int line, int pc) {
<span class="lineNum">     488 </span><span class="lineCov">        366 :   int n = l-&gt;n;</span>
<span class="lineNum">     489 </span><span class="lineCov">        366 :   luaM_growvector(ls-&gt;L, l-&gt;arr, n, l-&gt;size,</span>
<span class="lineNum">     490 </span>            :                   Labeldesc, SHRT_MAX, &quot;labels/gotos&quot;);
<span class="lineNum">     491 </span><span class="lineCov">        366 :   l-&gt;arr[n].name = name;</span>
<span class="lineNum">     492 </span><span class="lineCov">        366 :   l-&gt;arr[n].line = line;</span>
<span class="lineNum">     493 </span><span class="lineCov">        366 :   l-&gt;arr[n].nactvar = ls-&gt;fs-&gt;nactvar;</span>
<span class="lineNum">     494 </span><span class="lineCov">        366 :   l-&gt;arr[n].close = 0;</span>
<span class="lineNum">     495 </span><span class="lineCov">        366 :   l-&gt;arr[n].pc = pc;</span>
<span class="lineNum">     496 </span><span class="lineCov">        366 :   l-&gt;n = n + 1;</span>
<span class="lineNum">     497 </span><span class="lineCov">        366 :   return n;</span>
<span class="lineNum">     498 </span>            : }
<span class="lineNum">     499 </span>            : 
<span class="lineNum">     500 </span>            : 
<span class="lineNum">     501 </span><span class="lineCov">         18 : static int newgotoentry (LexState *ls, TString *name, int line, int pc) {</span>
<span class="lineNum">     502 </span><span class="lineCov">         18 :   return newlabelentry(ls, &amp;ls-&gt;dyd-&gt;gt, name, line, pc);</span>
<span class="lineNum">     503 </span>            : }
<span class="lineNum">     504 </span>            : 
<span class="lineNum">     505 </span>            : 
<span class="lineNum">     506 </span>            : /*
<span class="lineNum">     507 </span>            : ** Solves forward jumps. Check whether new label 'lb' matches any
<span class="lineNum">     508 </span>            : ** pending gotos in current block and solves them. Return true
<span class="lineNum">     509 </span>            : ** if any of the goto's need to close upvalues.
<span class="lineNum">     510 </span>            : */
<span class="lineNum">     511 </span><span class="lineCov">        348 : static int solvegotos (LexState *ls, Labeldesc *lb) {</span>
<span class="lineNum">     512 </span><span class="lineCov">        348 :   Labellist *gl = &amp;ls-&gt;dyd-&gt;gt;</span>
<span class="lineNum">     513 </span><span class="lineCov">        348 :   int i = ls-&gt;fs-&gt;bl-&gt;firstgoto;</span>
<span class="lineNum">     514 </span><span class="lineCov">        348 :   int needsclose = 0;</span>
<span class="lineNum">     515 </span><span class="lineCov">        363 :   while (i &lt; gl-&gt;n) {</span>
<span class="lineNum">     516 </span><span class="lineCov">         16 :     if (eqstr(gl-&gt;arr[i].name, lb-&gt;name)) {</span>
<span class="lineNum">     517 </span><span class="lineCov">         16 :       needsclose |= gl-&gt;arr[i].close;</span>
<span class="lineNum">     518 </span><span class="lineCov">         16 :       solvegoto(ls, i, lb);  /* will remove 'i' from the list */</span>
<span class="lineNum">     519 </span>            :     }
<span class="lineNum">     520 </span>            :     else
<span class="lineNum">     521 </span><span class="lineNoCov">          0 :       i++;</span>
<span class="lineNum">     522 </span>            :   }
<span class="lineNum">     523 </span><span class="lineCov">        347 :   return needsclose;</span>
<span class="lineNum">     524 </span>            : }
<span class="lineNum">     525 </span>            : 
<span class="lineNum">     526 </span>            : 
<span class="lineNum">     527 </span>            : /*
<span class="lineNum">     528 </span>            : ** Create a new label with the given 'name' at the given 'line'.
<span class="lineNum">     529 </span>            : ** 'last' tells whether label is the last non-op statement in its
<span class="lineNum">     530 </span>            : ** block. Solves all pending goto's to this new label and adds
<span class="lineNum">     531 </span>            : ** a close instruction if necessary.
<span class="lineNum">     532 </span>            : ** Returns true iff it added a close instruction.
<span class="lineNum">     533 </span>            : */
<span class="lineNum">     534 </span><span class="lineCov">        348 : static int createlabel (LexState *ls, TString *name, int line,</span>
<span class="lineNum">     535 </span>            :                         int last) {
<span class="lineNum">     536 </span><span class="lineCov">        348 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     537 </span><span class="lineCov">        348 :   Labellist *ll = &amp;ls-&gt;dyd-&gt;label;</span>
<span class="lineNum">     538 </span><span class="lineCov">        348 :   int l = newlabelentry(ls, ll, name, line, luaK_getlabel(fs));</span>
<span class="lineNum">     539 </span><span class="lineCov">        348 :   if (last) {  /* label is last no-op statement in the block? */</span>
<span class="lineNum">     540 </span>            :     /* assume that locals are already out of scope */
<span class="lineNum">     541 </span><span class="lineCov">          1 :     ll-&gt;arr[l].nactvar = fs-&gt;bl-&gt;nactvar;</span>
<span class="lineNum">     542 </span>            :   }
<span class="lineNum">     543 </span><span class="lineCov">        348 :   if (solvegotos(ls, &amp;ll-&gt;arr[l])) {  /* need close? */</span>
<span class="lineNum">     544 </span><span class="lineNoCov">          0 :     luaK_codeABC(fs, OP_CLOSE, fs-&gt;nactvar, 0, 0);</span>
<span class="lineNum">     545 </span><span class="lineNoCov">          0 :     return 1;</span>
<span class="lineNum">     546 </span>            :   }
<span class="lineNum">     547 </span><span class="lineCov">        347 :   return 0;</span>
<span class="lineNum">     548 </span>            : }
<span class="lineNum">     549 </span>            : 
<span class="lineNum">     550 </span>            : 
<span class="lineNum">     551 </span>            : /*
<span class="lineNum">     552 </span>            : ** Adjust pending gotos to outer level of a block.
<span class="lineNum">     553 </span>            : */
<span class="lineNum">     554 </span><span class="lineCov">       3036 : static void movegotosout (FuncState *fs, BlockCnt *bl) {</span>
<span class="lineNum">     555 </span>            :   int i;
<span class="lineNum">     556 </span><span class="lineCov">       3036 :   Labellist *gl = &amp;fs-&gt;ls-&gt;dyd-&gt;gt;</span>
<span class="lineNum">     557 </span>            :   /* correct pending gotos to current block */
<span class="lineNum">     558 </span><span class="lineCov">       3067 :   for (i = bl-&gt;firstgoto; i &lt; gl-&gt;n; i++) {  /* for each pending goto */</span>
<span class="lineNum">     559 </span><span class="lineCov">         31 :     Labeldesc *gt = &amp;gl-&gt;arr[i];</span>
<span class="lineNum">     560 </span><span class="lineCov">         31 :     if (gt-&gt;nactvar &gt; bl-&gt;nactvar) {  /* leaving a variable scope? */</span>
<span class="lineNum">     561 </span><span class="lineCov">         10 :       gt-&gt;nactvar = bl-&gt;nactvar;  /* update goto level */</span>
<span class="lineNum">     562 </span><span class="lineCov">         10 :       gt-&gt;close |= bl-&gt;upval;  /* jump may need a close */</span>
<span class="lineNum">     563 </span>            :     }
<span class="lineNum">     564 </span>            :   }
<span class="lineNum">     565 </span><span class="lineCov">       3036 : }</span>
<span class="lineNum">     566 </span>            : 
<span class="lineNum">     567 </span>            : 
<span class="lineNum">     568 </span><span class="lineCov">       5118 : static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isloop) {</span>
<span class="lineNum">     569 </span><span class="lineCov">       5118 :   bl-&gt;isloop = isloop;</span>
<span class="lineNum">     570 </span><span class="lineCov">       5118 :   bl-&gt;nactvar = fs-&gt;nactvar;</span>
<span class="lineNum">     571 </span><span class="lineCov">       5118 :   bl-&gt;firstlabel = fs-&gt;ls-&gt;dyd-&gt;label.n;</span>
<span class="lineNum">     572 </span><span class="lineCov">       5118 :   bl-&gt;firstgoto = fs-&gt;ls-&gt;dyd-&gt;gt.n;</span>
<span class="lineNum">     573 </span><span class="lineCov">       5118 :   bl-&gt;upval = 0;</span>
<span class="lineNum">     574 </span><span class="lineCov">       5118 :   bl-&gt;insidetbc = (fs-&gt;bl != NULL &amp;&amp; fs-&gt;bl-&gt;insidetbc);</span>
<span class="lineNum">     575 </span><span class="lineCov">       5118 :   bl-&gt;previous = fs-&gt;bl;</span>
<span class="lineNum">     576 </span><span class="lineCov">       5118 :   fs-&gt;bl = bl;</span>
<span class="lineNum">     577 </span>            :   lua_assert(fs-&gt;freereg == fs-&gt;nactvar);
<span class="lineNum">     578 </span><span class="lineCov">       5118 : }</span>
<span class="lineNum">     579 </span>            : 
<span class="lineNum">     580 </span>            : 
<span class="lineNum">     581 </span>            : /*
<span class="lineNum">     582 </span>            : ** generates an error for an undefined 'goto'.
<span class="lineNum">     583 </span>            : */
<span class="lineNum">     584 </span><span class="lineCov">          2 : static l_noret undefgoto (LexState *ls, Labeldesc *gt) {</span>
<span class="lineNum">     585 </span>            :   const char *msg;
<span class="lineNum">     586 </span><span class="lineCov">          2 :   if (eqstr(gt-&gt;name, luaS_newliteral(ls-&gt;L, &quot;break&quot;))) {</span>
<span class="lineNum">     587 </span><span class="lineCov">          1 :     msg = &quot;break outside loop at line %d&quot;;</span>
<span class="lineNum">     588 </span><span class="lineCov">          1 :     msg = luaO_pushfstring(ls-&gt;L, msg, gt-&gt;line);</span>
<span class="lineNum">     589 </span>            :   }
<span class="lineNum">     590 </span>            :   else {
<span class="lineNum">     591 </span><span class="lineCov">          1 :     msg = &quot;no visible label '%s' for &lt;goto&gt; at line %d&quot;;</span>
<span class="lineNum">     592 </span><span class="lineCov">          1 :     msg = luaO_pushfstring(ls-&gt;L, msg, getstr(gt-&gt;name), gt-&gt;line);</span>
<span class="lineNum">     593 </span>            :   }
<span class="lineNum">     594 </span><span class="lineCov">          2 :   luaK_semerror(ls, msg);</span>
<span class="lineNum">     595 </span>            : }
<span class="lineNum">     596 </span>            : 
<span class="lineNum">     597 </span>            : 
<span class="lineNum">     598 </span><span class="lineCov">       5065 : static void leaveblock (FuncState *fs) {</span>
<span class="lineNum">     599 </span><span class="lineCov">       5065 :   BlockCnt *bl = fs-&gt;bl;</span>
<span class="lineNum">     600 </span><span class="lineCov">       5065 :   LexState *ls = fs-&gt;ls;</span>
<span class="lineNum">     601 </span><span class="lineCov">       5065 :   int hasclose = 0;</span>
<span class="lineNum">     602 </span><span class="lineCov">       5065 :   if (bl-&gt;isloop)  /* fix pending breaks? */</span>
<span class="lineNum">     603 </span><span class="lineCov">        341 :     hasclose = createlabel(ls, luaS_newliteral(ls-&gt;L, &quot;break&quot;), 0, 0);</span>
<span class="lineNum">     604 </span><span class="lineCov">       5065 :   if (!hasclose &amp;&amp; bl-&gt;previous &amp;&amp; bl-&gt;upval)</span>
<span class="lineNum">     605 </span><span class="lineCov">        110 :     luaK_codeABC(fs, OP_CLOSE, bl-&gt;nactvar, 0, 0);</span>
<span class="lineNum">     606 </span><span class="lineCov">       5065 :   fs-&gt;bl = bl-&gt;previous;</span>
<span class="lineNum">     607 </span><span class="lineCov">       5065 :   removevars(fs, bl-&gt;nactvar);</span>
<span class="lineNum">     608 </span>            :   lua_assert(bl-&gt;nactvar == fs-&gt;nactvar);
<span class="lineNum">     609 </span><span class="lineCov">       5065 :   fs-&gt;freereg = fs-&gt;nactvar;  /* free registers */</span>
<span class="lineNum">     610 </span><span class="lineCov">       5065 :   ls-&gt;dyd-&gt;label.n = bl-&gt;firstlabel;  /* remove local labels */</span>
<span class="lineNum">     611 </span><span class="lineCov">       5065 :   if (bl-&gt;previous)  /* inner block? */</span>
<span class="lineNum">     612 </span><span class="lineCov">       3036 :     movegotosout(fs, bl);  /* update pending gotos to outer block */</span>
<span class="lineNum">     613 </span>            :   else {
<span class="lineNum">     614 </span><span class="lineCov">       2029 :     if (bl-&gt;firstgoto &lt; ls-&gt;dyd-&gt;gt.n)  /* pending gotos in outer block? */</span>
<span class="lineNum">     615 </span><span class="lineCov">          2 :       undefgoto(ls, &amp;ls-&gt;dyd-&gt;gt.arr[bl-&gt;firstgoto]);  /* error */</span>
<span class="lineNum">     616 </span>            :   }
<span class="lineNum">     617 </span><span class="lineCov">       5063 : }</span>
<span class="lineNum">     618 </span>            : 
<span class="lineNum">     619 </span>            : 
<span class="lineNum">     620 </span>            : /*
<span class="lineNum">     621 </span>            : ** adds a new prototype into list of prototypes
<span class="lineNum">     622 </span>            : */
<span class="lineNum">     623 </span><span class="lineCov">       1562 : static Proto *addprototype (LexState *ls) {</span>
<span class="lineNum">     624 </span>            :   Proto *clp;
<span class="lineNum">     625 </span><span class="lineCov">       1562 :   lua_State *L = ls-&gt;L;</span>
<span class="lineNum">     626 </span><span class="lineCov">       1562 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     627 </span><span class="lineCov">       1562 :   Proto *f = fs-&gt;f;  /* prototype of current function */</span>
<span class="lineNum">     628 </span><span class="lineCov">       1562 :   if (fs-&gt;np &gt;= f-&gt;sizep) {</span>
<span class="lineNum">     629 </span><span class="lineCov">        349 :     int oldsize = f-&gt;sizep;</span>
<span class="lineNum">     630 </span><span class="lineCov">        349 :     luaM_growvector(L, f-&gt;p, fs-&gt;np, f-&gt;sizep, Proto *, MAXARG_Bx, &quot;functions&quot;);</span>
<span class="lineNum">     631 </span><span class="lineCov">       2925 :     while (oldsize &lt; f-&gt;sizep)</span>
<span class="lineNum">     632 </span><span class="lineCov">       2576 :       f-&gt;p[oldsize++] = NULL;</span>
<span class="lineNum">     633 </span>            :   }
<span class="lineNum">     634 </span><span class="lineCov">       1562 :   f-&gt;p[fs-&gt;np++] = clp = luaF_newproto(L);</span>
<span class="lineNum">     635 </span><span class="lineCov">       1562 :   luaC_objbarrier(L, f, clp);</span>
<span class="lineNum">     636 </span><span class="lineCov">       1562 :   return clp;</span>
<span class="lineNum">     637 </span>            : }
<span class="lineNum">     638 </span>            : 
<span class="lineNum">     639 </span>            : 
<span class="lineNum">     640 </span>            : /*
<span class="lineNum">     641 </span>            : ** codes instruction to create new closure in parent function.
<span class="lineNum">     642 </span>            : ** The OP_CLOSURE instruction must use the last available register,
<span class="lineNum">     643 </span>            : ** so that, if it invokes the GC, the GC knows which registers
<span class="lineNum">     644 </span>            : ** are in use at that time.
<span class="lineNum">     645 </span>            : */
<span class="lineNum">     646 </span><span class="lineCov">       1559 : static void codeclosure (LexState *ls, expdesc *v) {</span>
<span class="lineNum">     647 </span><span class="lineCov">       1559 :   FuncState *fs = ls-&gt;fs-&gt;prev;</span>
<span class="lineNum">     648 </span><span class="lineCov">       1559 :   init_exp(v, VRELOC, luaK_codeABx(fs, OP_CLOSURE, 0, fs-&gt;np - 1));</span>
<span class="lineNum">     649 </span><span class="lineCov">       1559 :   luaK_exp2nextreg(fs, v);  /* fix it at the last register */</span>
<span class="lineNum">     650 </span><span class="lineCov">       1559 : }</span>
<span class="lineNum">     651 </span>            : 
<span class="lineNum">     652 </span>            : 
<span class="lineNum">     653 </span><span class="lineCov">       2075 : static void open_func (LexState *ls, FuncState *fs, BlockCnt *bl) {</span>
<span class="lineNum">     654 </span><span class="lineCov">       2075 :   Proto *f = fs-&gt;f;</span>
<span class="lineNum">     655 </span><span class="lineCov">       2075 :   fs-&gt;prev = ls-&gt;fs;  /* linked list of funcstates */</span>
<span class="lineNum">     656 </span><span class="lineCov">       2075 :   fs-&gt;ls = ls;</span>
<span class="lineNum">     657 </span><span class="lineCov">       2075 :   ls-&gt;fs = fs;</span>
<span class="lineNum">     658 </span><span class="lineCov">       2075 :   fs-&gt;pc = 0;</span>
<span class="lineNum">     659 </span><span class="lineCov">       2075 :   fs-&gt;previousline = f-&gt;linedefined;</span>
<span class="lineNum">     660 </span><span class="lineCov">       2075 :   fs-&gt;iwthabs = 0;</span>
<span class="lineNum">     661 </span><span class="lineCov">       2075 :   fs-&gt;lasttarget = 0;</span>
<span class="lineNum">     662 </span><span class="lineCov">       2075 :   fs-&gt;freereg = 0;</span>
<span class="lineNum">     663 </span><span class="lineCov">       2075 :   fs-&gt;nk = 0;</span>
<span class="lineNum">     664 </span><span class="lineCov">       2075 :   fs-&gt;nabslineinfo = 0;</span>
<span class="lineNum">     665 </span><span class="lineCov">       2075 :   fs-&gt;np = 0;</span>
<span class="lineNum">     666 </span><span class="lineCov">       2075 :   fs-&gt;nups = 0;</span>
<span class="lineNum">     667 </span><span class="lineCov">       2075 :   fs-&gt;nlocvars = 0;</span>
<span class="lineNum">     668 </span><span class="lineCov">       2075 :   fs-&gt;nactvar = 0;</span>
<span class="lineNum">     669 </span><span class="lineCov">       2075 :   fs-&gt;needclose = 0;</span>
<span class="lineNum">     670 </span><span class="lineCov">       2075 :   fs-&gt;firstlocal = ls-&gt;dyd-&gt;actvar.n;</span>
<span class="lineNum">     671 </span><span class="lineCov">       2075 :   fs-&gt;firstlabel = ls-&gt;dyd-&gt;label.n;</span>
<span class="lineNum">     672 </span><span class="lineCov">       2075 :   fs-&gt;bl = NULL;</span>
<span class="lineNum">     673 </span><span class="lineCov">       2075 :   f-&gt;source = ls-&gt;source;</span>
<span class="lineNum">     674 </span><span class="lineCov">       2075 :   f-&gt;maxstacksize = 2;  /* registers 0/1 are always valid */</span>
<span class="lineNum">     675 </span><span class="lineCov">       2075 :   enterblock(fs, bl, 0);</span>
<span class="lineNum">     676 </span><span class="lineCov">       2075 : }</span>
<span class="lineNum">     677 </span>            : 
<span class="lineNum">     678 </span>            : 
<span class="lineNum">     679 </span><span class="lineCov">       2029 : static void close_func (LexState *ls) {</span>
<span class="lineNum">     680 </span><span class="lineCov">       2029 :   lua_State *L = ls-&gt;L;</span>
<span class="lineNum">     681 </span><span class="lineCov">       2029 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     682 </span><span class="lineCov">       2029 :   Proto *f = fs-&gt;f;</span>
<span class="lineNum">     683 </span><span class="lineCov">       2029 :   luaK_ret(fs, fs-&gt;nactvar, 0);  /* final return */</span>
<span class="lineNum">     684 </span><span class="lineCov">       2029 :   leaveblock(fs);</span>
<span class="lineNum">     685 </span>            :   lua_assert(fs-&gt;bl == NULL);
<span class="lineNum">     686 </span><span class="lineCov">       2027 :   luaK_finish(fs);</span>
<span class="lineNum">     687 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;code, f-&gt;sizecode, fs-&gt;pc, Instruction);</span>
<span class="lineNum">     688 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;lineinfo, f-&gt;sizelineinfo, fs-&gt;pc, ls_byte);</span>
<span class="lineNum">     689 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;abslineinfo, f-&gt;sizeabslineinfo,</span>
<span class="lineNum">     690 </span>            :                        fs-&gt;nabslineinfo, AbsLineInfo);
<span class="lineNum">     691 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;k, f-&gt;sizek, fs-&gt;nk, TValue);</span>
<span class="lineNum">     692 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;p, f-&gt;sizep, fs-&gt;np, Proto *);</span>
<span class="lineNum">     693 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;locvars, f-&gt;sizelocvars, fs-&gt;nlocvars, LocVar);</span>
<span class="lineNum">     694 </span><span class="lineCov">       2027 :   luaM_shrinkvector(L, f-&gt;upvalues, f-&gt;sizeupvalues, fs-&gt;nups, Upvaldesc);</span>
<span class="lineNum">     695 </span><span class="lineCov">       2027 :   ls-&gt;fs = fs-&gt;prev;</span>
<span class="lineNum">     696 </span><span class="lineCov">       2027 :   luaC_checkGC(L);</span>
<span class="lineNum">     697 </span><span class="lineCov">       2027 : }</span>
<span class="lineNum">     698 </span>            : 
<span class="lineNum">     699 </span>            : 
<span class="lineNum">     700 </span>            : 
<span class="lineNum">     701 </span>            : /*============================================================*/
<span class="lineNum">     702 </span>            : /* GRAMMAR RULES */
<span class="lineNum">     703 </span>            : /*============================================================*/
<span class="lineNum">     704 </span>            : 
<span class="lineNum">     705 </span>            : 
<span class="lineNum">     706 </span>            : /*
<span class="lineNum">     707 </span>            : ** check whether current token is in the follow set of a block.
<span class="lineNum">     708 </span>            : ** 'until' closes syntactical blocks, but do not close scope,
<span class="lineNum">     709 </span>            : ** so it is handled in separate.
<span class="lineNum">     710 </span>            : */
<span class="lineNum">     711 </span><span class="lineCov">      16573 : static int block_follow (LexState *ls, int withuntil) {</span>
<span class="lineNum">     712 </span><span class="lineCov">      16573 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">     713 </span><span class="lineCov">       3502 :     case TK_ELSE: case TK_ELSEIF:</span>
<span class="lineNum">     714 </span>            :     case TK_END: case TK_EOS:
<span class="lineNum">     715 </span><span class="lineCov">       3502 :       return 1;</span>
<span class="lineNum">     716 </span><span class="lineCov">          3 :     case TK_UNTIL: return withuntil;</span>
<span class="lineNum">     717 </span><span class="lineCov">      13068 :     default: return 0;</span>
<span class="lineNum">     718 </span>            :   }
<span class="lineNum">     719 </span>            : }
<span class="lineNum">     720 </span>            : 
<span class="lineNum">     721 </span>            : 
<span class="lineNum">     722 </span><span class="lineCov">       4441 : static void statlist (LexState *ls) {</span>
<span class="lineNum">     723 </span>            :   /* statlist -&gt; { stat [';'] } */
<span class="lineNum">     724 </span><span class="lineCov">      15566 :   while (!block_follow(ls, 1)) {</span>
<span class="lineNum">     725 </span><span class="lineCov">      12160 :     if (ls-&gt;t.token == TK_RETURN) {</span>
<span class="lineNum">     726 </span><span class="lineCov">        992 :       statement(ls);</span>
<span class="lineNum">     727 </span><span class="lineCov">        992 :       return;  /* 'return' must be last statement */</span>
<span class="lineNum">     728 </span>            :     }
<span class="lineNum">     729 </span><span class="lineCov">      11168 :     statement(ls);</span>
<span class="lineNum">     730 </span>            :   }
<span class="lineNum">     731 </span>            : }
<span class="lineNum">     732 </span>            : 
<span class="lineNum">     733 </span>            : 
<span class="lineNum">     734 </span><span class="lineCov">       2096 : static void fieldsel (LexState *ls, expdesc *v) {</span>
<span class="lineNum">     735 </span>            :   /* fieldsel -&gt; ['.' | ':'] NAME */
<span class="lineNum">     736 </span><span class="lineCov">       2096 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     737 </span>            :   expdesc key;
<span class="lineNum">     738 </span><span class="lineCov">       2096 :   luaK_exp2anyregup(fs, v);</span>
<span class="lineNum">     739 </span><span class="lineCov">       2096 :   luaX_next(ls);  /* skip the dot or colon */</span>
<span class="lineNum">     740 </span><span class="lineCov">       2096 :   codename(ls, &amp;key);</span>
<span class="lineNum">     741 </span><span class="lineCov">       2096 :   luaK_indexed(fs, v, &amp;key);</span>
<span class="lineNum">     742 </span><span class="lineCov">       2096 : }</span>
<span class="lineNum">     743 </span>            : 
<span class="lineNum">     744 </span>            : 
<span class="lineNum">     745 </span><span class="lineCov">        656 : static void yindex (LexState *ls, expdesc *v) {</span>
<span class="lineNum">     746 </span>            :   /* index -&gt; '[' expr ']' */
<span class="lineNum">     747 </span><span class="lineCov">        656 :   luaX_next(ls);  /* skip the '[' */</span>
<span class="lineNum">     748 </span><span class="lineCov">        656 :   expr(ls, v);</span>
<span class="lineNum">     749 </span><span class="lineCov">        656 :   luaK_exp2val(ls-&gt;fs, v);</span>
<span class="lineNum">     750 </span><span class="lineCov">        656 :   checknext(ls, ']');</span>
<span class="lineNum">     751 </span><span class="lineCov">        656 : }</span>
<span class="lineNum">     752 </span>            : 
<span class="lineNum">     753 </span>            : 
<span class="lineNum">     754 </span>            : /*
<span class="lineNum">     755 </span>            : ** {======================================================================
<span class="lineNum">     756 </span>            : ** Rules for Constructors
<span class="lineNum">     757 </span>            : ** =======================================================================
<span class="lineNum">     758 </span>            : */
<span class="lineNum">     759 </span>            : 
<span class="lineNum">     760 </span>            : 
<span class="lineNum">     761 </span>            : struct ConsControl {
<span class="lineNum">     762 </span>            :   expdesc v;  /* last list item read */
<span class="lineNum">     763 </span>            :   expdesc *t;  /* table descriptor */
<span class="lineNum">     764 </span>            :   int nh;  /* total number of 'record' elements */
<span class="lineNum">     765 </span>            :   int na;  /* total number of array elements */
<span class="lineNum">     766 </span>            :   int tostore;  /* number of array elements pending to be stored */
<span class="lineNum">     767 </span>            : };
<span class="lineNum">     768 </span>            : 
<span class="lineNum">     769 </span>            : 
<span class="lineNum">     770 </span><span class="lineCov">        272 : static void recfield (LexState *ls, struct ConsControl *cc) {</span>
<span class="lineNum">     771 </span>            :   /* recfield -&gt; (NAME | '['exp']') = exp */
<span class="lineNum">     772 </span><span class="lineCov">        272 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     773 </span><span class="lineCov">        272 :   int reg = ls-&gt;fs-&gt;freereg;</span>
<span class="lineNum">     774 </span>            :   expdesc tab, key, val;
<span class="lineNum">     775 </span><span class="lineCov">        272 :   if (ls-&gt;t.token == TK_NAME) {</span>
<span class="lineNum">     776 </span><span class="lineCov">        261 :     checklimit(fs, cc-&gt;nh, MAX_INT, &quot;items in a constructor&quot;);</span>
<span class="lineNum">     777 </span><span class="lineCov">        261 :     codename(ls, &amp;key);</span>
<span class="lineNum">     778 </span>            :   }
<span class="lineNum">     779 </span>            :   else  /* ls-&gt;t.token == '[' */
<span class="lineNum">     780 </span><span class="lineCov">         11 :     yindex(ls, &amp;key);</span>
<span class="lineNum">     781 </span><span class="lineCov">        272 :   cc-&gt;nh++;</span>
<span class="lineNum">     782 </span><span class="lineCov">        272 :   checknext(ls, '=');</span>
<span class="lineNum">     783 </span><span class="lineCov">        272 :   tab = *cc-&gt;t;</span>
<span class="lineNum">     784 </span><span class="lineCov">        272 :   luaK_indexed(fs, &amp;tab, &amp;key);</span>
<span class="lineNum">     785 </span><span class="lineCov">        272 :   expr(ls, &amp;val);</span>
<span class="lineNum">     786 </span><span class="lineCov">        272 :   luaK_storevar(fs, &amp;tab, &amp;val);</span>
<span class="lineNum">     787 </span><span class="lineCov">        272 :   fs-&gt;freereg = reg;  /* free registers */</span>
<span class="lineNum">     788 </span><span class="lineCov">        272 : }</span>
<span class="lineNum">     789 </span>            : 
<span class="lineNum">     790 </span>            : 
<span class="lineNum">     791 </span><span class="lineCov">       1325 : static void closelistfield (FuncState *fs, struct ConsControl *cc) {</span>
<span class="lineNum">     792 </span><span class="lineCov">       1325 :   if (cc-&gt;v.k == VVOID) return;  /* there is no list item */</span>
<span class="lineNum">     793 </span><span class="lineCov">        655 :   luaK_exp2nextreg(fs, &amp;cc-&gt;v);</span>
<span class="lineNum">     794 </span><span class="lineCov">        655 :   cc-&gt;v.k = VVOID;</span>
<span class="lineNum">     795 </span><span class="lineCov">        655 :   if (cc-&gt;tostore == LFIELDS_PER_FLUSH) {</span>
<span class="lineNum">     796 </span><span class="lineCov">          4 :     luaK_setlist(fs, cc-&gt;t-&gt;u.info, cc-&gt;na, cc-&gt;tostore);  /* flush */</span>
<span class="lineNum">     797 </span><span class="lineCov">          4 :     cc-&gt;tostore = 0;  /* no more items pending */</span>
<span class="lineNum">     798 </span>            :   }
<span class="lineNum">     799 </span>            : }
<span class="lineNum">     800 </span>            : 
<span class="lineNum">     801 </span>            : 
<span class="lineNum">     802 </span><span class="lineCov">        696 : static void lastlistfield (FuncState *fs, struct ConsControl *cc) {</span>
<span class="lineNum">     803 </span><span class="lineCov">        696 :   if (cc-&gt;tostore == 0) return;</span>
<span class="lineNum">     804 </span><span class="lineCov">        398 :   if (hasmultret(cc-&gt;v.k)) {</span>
<span class="lineNum">     805 </span><span class="lineCov">        234 :     luaK_setmultret(fs, &amp;cc-&gt;v);</span>
<span class="lineNum">     806 </span><span class="lineCov">        234 :     luaK_setlist(fs, cc-&gt;t-&gt;u.info, cc-&gt;na, LUA_MULTRET);</span>
<span class="lineNum">     807 </span><span class="lineCov">        234 :     cc-&gt;na--;  /* do not count last expression (unknown number of elements) */</span>
<span class="lineNum">     808 </span>            :   }
<span class="lineNum">     809 </span>            :   else {
<span class="lineNum">     810 </span><span class="lineCov">        164 :     if (cc-&gt;v.k != VVOID)</span>
<span class="lineNum">     811 </span><span class="lineCov">        163 :       luaK_exp2nextreg(fs, &amp;cc-&gt;v);</span>
<span class="lineNum">     812 </span><span class="lineCov">        164 :     luaK_setlist(fs, cc-&gt;t-&gt;u.info, cc-&gt;na, cc-&gt;tostore);</span>
<span class="lineNum">     813 </span>            :   }
<span class="lineNum">     814 </span>            : }
<span class="lineNum">     815 </span>            : 
<span class="lineNum">     816 </span>            : 
<span class="lineNum">     817 </span><span class="lineCov">       1053 : static void listfield (LexState *ls, struct ConsControl *cc) {</span>
<span class="lineNum">     818 </span>            :   /* listfield -&gt; exp */
<span class="lineNum">     819 </span><span class="lineCov">       1053 :   expr(ls, &amp;cc-&gt;v);</span>
<span class="lineNum">     820 </span><span class="lineCov">       1053 :   checklimit(ls-&gt;fs, cc-&gt;na, MAX_INT, &quot;items in a constructor&quot;);</span>
<span class="lineNum">     821 </span><span class="lineCov">       1053 :   cc-&gt;na++;</span>
<span class="lineNum">     822 </span><span class="lineCov">       1053 :   cc-&gt;tostore++;</span>
<span class="lineNum">     823 </span><span class="lineCov">       1053 : }</span>
<span class="lineNum">     824 </span>            : 
<span class="lineNum">     825 </span>            : 
<span class="lineNum">     826 </span><span class="lineCov">       1325 : static void field (LexState *ls, struct ConsControl *cc) {</span>
<span class="lineNum">     827 </span>            :   /* field -&gt; listfield | recfield */
<span class="lineNum">     828 </span><span class="lineCov">       1325 :   switch(ls-&gt;t.token) {</span>
<span class="lineNum">     829 </span><span class="lineCov">        497 :     case TK_NAME: {  /* may be 'listfield' or 'recfield' */</span>
<span class="lineNum">     830 </span><span class="lineCov">        497 :       if (luaX_lookahead(ls) != '=')  /* expression? */</span>
<span class="lineNum">     831 </span><span class="lineCov">        236 :         listfield(ls, cc);</span>
<span class="lineNum">     832 </span>            :       else
<span class="lineNum">     833 </span><span class="lineCov">        261 :         recfield(ls, cc);</span>
<span class="lineNum">     834 </span><span class="lineCov">        497 :       break;</span>
<span class="lineNum">     835 </span>            :     }
<span class="lineNum">     836 </span><span class="lineCov">         11 :     case '[': {</span>
<span class="lineNum">     837 </span><span class="lineCov">         11 :       recfield(ls, cc);</span>
<span class="lineNum">     838 </span><span class="lineCov">         11 :       break;</span>
<span class="lineNum">     839 </span>            :     }
<span class="lineNum">     840 </span><span class="lineCov">        817 :     default: {</span>
<span class="lineNum">     841 </span><span class="lineCov">        817 :       listfield(ls, cc);</span>
<span class="lineNum">     842 </span><span class="lineCov">        817 :       break;</span>
<span class="lineNum">     843 </span>            :     }
<span class="lineNum">     844 </span>            :   }
<span class="lineNum">     845 </span><span class="lineCov">       1325 : }</span>
<span class="lineNum">     846 </span>            : 
<span class="lineNum">     847 </span>            : 
<span class="lineNum">     848 </span><span class="lineCov">        697 : static void constructor (LexState *ls, expdesc *t) {</span>
<span class="lineNum">     849 </span>            :   /* constructor -&gt; '{' [ field { sep field } [sep] ] '}'
<span class="lineNum">     850 </span>            :      sep -&gt; ',' | ';' */
<span class="lineNum">     851 </span><span class="lineCov">        697 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     852 </span><span class="lineCov">        697 :   int line = ls-&gt;linenumber;</span>
<span class="lineNum">     853 </span><span class="lineCov">        697 :   int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);</span>
<span class="lineNum">     854 </span>            :   struct ConsControl cc;
<span class="lineNum">     855 </span><span class="lineCov">        697 :   cc.na = cc.nh = cc.tostore = 0;</span>
<span class="lineNum">     856 </span><span class="lineCov">        697 :   cc.t = t;</span>
<span class="lineNum">     857 </span><span class="lineCov">        697 :   init_exp(t, VRELOC, pc);</span>
<span class="lineNum">     858 </span><span class="lineCov">        697 :   init_exp(&amp;cc.v, VVOID, 0);  /* no value (yet) */</span>
<span class="lineNum">     859 </span><span class="lineCov">        697 :   luaK_exp2nextreg(ls-&gt;fs, t);  /* fix it at stack top */</span>
<span class="lineNum">     860 </span><span class="lineCov">        697 :   checknext(ls, '{');</span>
<span class="lineNum">     861 </span>            :   do {
<span class="lineNum">     862 </span>            :     lua_assert(cc.v.k == VVOID || cc.tostore &gt; 0);
<span class="lineNum">     863 </span><span class="lineCov">       1568 :     if (ls-&gt;t.token == '}') break;</span>
<span class="lineNum">     864 </span><span class="lineCov">       1325 :     closelistfield(fs, &amp;cc);</span>
<span class="lineNum">     865 </span><span class="lineCov">       1325 :     field(ls, &amp;cc);</span>
<span class="lineNum">     866 </span><span class="lineCov">       1325 :   } while (testnext(ls, ',') || testnext(ls, ';'));</span>
<span class="lineNum">     867 </span><span class="lineCov">        697 :   check_match(ls, '}', '{', line);</span>
<span class="lineNum">     868 </span><span class="lineCov">        696 :   lastlistfield(fs, &amp;cc);</span>
<span class="lineNum">     869 </span><span class="lineCov">        696 :   SETARG_B(fs-&gt;f-&gt;code[pc], luaO_int2fb(cc.na)); /* set initial array size */</span>
<span class="lineNum">     870 </span><span class="lineCov">        696 :   SETARG_C(fs-&gt;f-&gt;code[pc], luaO_int2fb(cc.nh));  /* set initial table size */</span>
<span class="lineNum">     871 </span><span class="lineCov">        696 : }</span>
<span class="lineNum">     872 </span>            : 
<span class="lineNum">     873 </span>            : /* }====================================================================== */
<span class="lineNum">     874 </span>            : 
<span class="lineNum">     875 </span>            : 
<span class="lineNum">     876 </span><span class="lineCov">        530 : static void setvararg (FuncState *fs, int nparams) {</span>
<span class="lineNum">     877 </span><span class="lineCov">        530 :   fs-&gt;f-&gt;is_vararg = 1;</span>
<span class="lineNum">     878 </span><span class="lineCov">        530 :   luaK_codeABC(fs, OP_VARARGPREP, nparams, 0, 0);</span>
<span class="lineNum">     879 </span><span class="lineCov">        530 : }</span>
<span class="lineNum">     880 </span>            : 
<span class="lineNum">     881 </span>            : 
<span class="lineNum">     882 </span><span class="lineCov">       1562 : static void parlist (LexState *ls) {</span>
<span class="lineNum">     883 </span>            :   /* parlist -&gt; [ param { ',' param } ] */
<span class="lineNum">     884 </span><span class="lineCov">       1562 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     885 </span><span class="lineCov">       1562 :   Proto *f = fs-&gt;f;</span>
<span class="lineNum">     886 </span><span class="lineCov">       1562 :   int nparams = 0;</span>
<span class="lineNum">     887 </span><span class="lineCov">       1562 :   int isvararg = 0;</span>
<span class="lineNum">     888 </span><span class="lineCov">       1562 :   if (ls-&gt;t.token != ')') {  /* is 'parlist' not empty? */</span>
<span class="lineNum">     889 </span>            :     do {
<span class="lineNum">     890 </span><span class="lineCov">       1816 :       switch (ls-&gt;t.token) {</span>
<span class="lineNum">     891 </span><span class="lineCov">       1798 :         case TK_NAME: {  /* param -&gt; NAME */</span>
<span class="lineNum">     892 </span><span class="lineCov">       1798 :           new_localvar(ls, str_checkname(ls));</span>
<span class="lineNum">     893 </span><span class="lineCov">       1798 :           nparams++;</span>
<span class="lineNum">     894 </span><span class="lineCov">       1798 :           break;</span>
<span class="lineNum">     895 </span>            :         }
<span class="lineNum">     896 </span><span class="lineCov">         17 :         case TK_DOTS: {  /* param -&gt; '...' */</span>
<span class="lineNum">     897 </span><span class="lineCov">         17 :           luaX_next(ls);</span>
<span class="lineNum">     898 </span><span class="lineCov">         17 :           isvararg = 1;</span>
<span class="lineNum">     899 </span><span class="lineCov">         17 :           break;</span>
<span class="lineNum">     900 </span>            :         }
<span class="lineNum">     901 </span><span class="lineCov">          1 :         default: luaX_syntaxerror(ls, &quot;&lt;name&gt; or '...' expected&quot;);</span>
<span class="lineNum">     902 </span>            :       }
<span class="lineNum">     903 </span><span class="lineCov">       1815 :     } while (!isvararg &amp;&amp; testnext(ls, ','));</span>
<span class="lineNum">     904 </span>            :   }
<span class="lineNum">     905 </span><span class="lineCov">       1561 :   adjustlocalvars(ls, nparams);</span>
<span class="lineNum">     906 </span><span class="lineCov">       1561 :   f-&gt;numparams = cast_byte(fs-&gt;nactvar);</span>
<span class="lineNum">     907 </span><span class="lineCov">       1561 :   if (isvararg)</span>
<span class="lineNum">     908 </span><span class="lineCov">         17 :     setvararg(fs, f-&gt;numparams);  /* declared vararg */</span>
<span class="lineNum">     909 </span><span class="lineCov">       1561 :   luaK_reserveregs(fs, fs-&gt;nactvar);  /* reserve registers for parameters */</span>
<span class="lineNum">     910 </span><span class="lineCov">       1561 : }</span>
<span class="lineNum">     911 </span>            : 
<span class="lineNum">     912 </span>            : 
<span class="lineNum">     913 </span><span class="lineCov">       1562 : static void body (LexState *ls, expdesc *e, int ismethod, int line) {</span>
<span class="lineNum">     914 </span>            :   /* body -&gt;  '(' parlist ')' block END */
<span class="lineNum">     915 </span>            :   FuncState new_fs;
<span class="lineNum">     916 </span>            :   BlockCnt bl;
<span class="lineNum">     917 </span><span class="lineCov">       1562 :   new_fs.f = addprototype(ls);</span>
<span class="lineNum">     918 </span><span class="lineCov">       1562 :   new_fs.f-&gt;linedefined = line;</span>
<span class="lineNum">     919 </span><span class="lineCov">       1562 :   open_func(ls, &amp;new_fs, &amp;bl);</span>
<span class="lineNum">     920 </span><span class="lineCov">       1562 :   checknext(ls, '(');</span>
<span class="lineNum">     921 </span><span class="lineCov">       1562 :   if (ismethod) {</span>
<span class="lineNum">     922 </span><span class="lineCov">         20 :     new_localvarliteral(ls, &quot;self&quot;);  /* create 'self' parameter */</span>
<span class="lineNum">     923 </span><span class="lineCov">         20 :     adjustlocalvars(ls, 1);</span>
<span class="lineNum">     924 </span>            :   }
<span class="lineNum">     925 </span><span class="lineCov">       1562 :   parlist(ls);</span>
<span class="lineNum">     926 </span><span class="lineCov">       1561 :   checknext(ls, ')');</span>
<span class="lineNum">     927 </span><span class="lineCov">       1561 :   statlist(ls);</span>
<span class="lineNum">     928 </span><span class="lineCov">       1560 :   new_fs.f-&gt;lastlinedefined = ls-&gt;linenumber;</span>
<span class="lineNum">     929 </span><span class="lineCov">       1560 :   check_match(ls, TK_END, TK_FUNCTION, line);</span>
<span class="lineNum">     930 </span><span class="lineCov">       1559 :   codeclosure(ls, e);</span>
<span class="lineNum">     931 </span><span class="lineCov">       1559 :   close_func(ls);</span>
<span class="lineNum">     932 </span><span class="lineCov">       1558 : }</span>
<span class="lineNum">     933 </span>            : 
<span class="lineNum">     934 </span>            : 
<span class="lineNum">     935 </span><span class="lineCov">      11432 : static int explist (LexState *ls, expdesc *v) {</span>
<span class="lineNum">     936 </span>            :   /* explist -&gt; expr { ',' expr } */
<span class="lineNum">     937 </span><span class="lineCov">      11432 :   int n = 1;  /* at least one expression */</span>
<span class="lineNum">     938 </span><span class="lineCov">      11432 :   expr(ls, v);</span>
<span class="lineNum">     939 </span><span class="lineCov">      17155 :   while (testnext(ls, ',')) {</span>
<span class="lineNum">     940 </span><span class="lineCov">       5728 :     luaK_exp2nextreg(ls-&gt;fs, v);</span>
<span class="lineNum">     941 </span><span class="lineCov">       5728 :     expr(ls, v);</span>
<span class="lineNum">     942 </span><span class="lineCov">       5728 :     n++;</span>
<span class="lineNum">     943 </span>            :   }
<span class="lineNum">     944 </span><span class="lineCov">      11427 :   return n;</span>
<span class="lineNum">     945 </span>            : }
<span class="lineNum">     946 </span>            : 
<span class="lineNum">     947 </span>            : 
<span class="lineNum">     948 </span><span class="lineCov">       8008 : static void funcargs (LexState *ls, expdesc *f, int line) {</span>
<span class="lineNum">     949 </span><span class="lineCov">       8008 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">     950 </span>            :   expdesc args;
<span class="lineNum">     951 </span>            :   int base, nparams;
<span class="lineNum">     952 </span><span class="lineCov">       8008 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">     953 </span><span class="lineCov">       7591 :     case '(': {  /* funcargs -&gt; '(' [ explist ] ')' */</span>
<span class="lineNum">     954 </span><span class="lineCov">       7591 :       luaX_next(ls);</span>
<span class="lineNum">     955 </span><span class="lineCov">       7591 :       if (ls-&gt;t.token == ')')  /* arg list is empty? */</span>
<span class="lineNum">     956 </span><span class="lineCov">        356 :         args.k = VVOID;</span>
<span class="lineNum">     957 </span>            :       else {
<span class="lineNum">     958 </span><span class="lineCov">       7235 :         explist(ls, &amp;args);</span>
<span class="lineNum">     959 </span><span class="lineCov">       7234 :         luaK_setmultret(fs, &amp;args);</span>
<span class="lineNum">     960 </span>            :       }
<span class="lineNum">     961 </span><span class="lineCov">       7590 :       check_match(ls, ')', '(', line);</span>
<span class="lineNum">     962 </span><span class="lineCov">       7589 :       break;</span>
<span class="lineNum">     963 </span>            :     }
<span class="lineNum">     964 </span><span class="lineCov">         14 :     case '{': {  /* funcargs -&gt; constructor */</span>
<span class="lineNum">     965 </span><span class="lineCov">         14 :       constructor(ls, &amp;args);</span>
<span class="lineNum">     966 </span><span class="lineCov">         14 :       break;</span>
<span class="lineNum">     967 </span>            :     }
<span class="lineNum">     968 </span><span class="lineCov">        402 :     case TK_STRING: {  /* funcargs -&gt; STRING */</span>
<span class="lineNum">     969 </span><span class="lineCov">        402 :       codestring(ls, &amp;args, ls-&gt;t.seminfo.ts);</span>
<span class="lineNum">     970 </span><span class="lineCov">        402 :       luaX_next(ls);  /* must use 'seminfo' before 'next' */</span>
<span class="lineNum">     971 </span><span class="lineCov">        402 :       break;</span>
<span class="lineNum">     972 </span>            :     }
<span class="lineNum">     973 </span><span class="lineCov">          1 :     default: {</span>
<span class="lineNum">     974 </span><span class="lineCov">          1 :       luaX_syntaxerror(ls, &quot;function arguments expected&quot;);</span>
<span class="lineNum">     975 </span>            :     }
<span class="lineNum">     976 </span>            :   }
<span class="lineNum">     977 </span>            :   lua_assert(f-&gt;k == VNONRELOC);
<span class="lineNum">     978 </span><span class="lineCov">       8005 :   base = f-&gt;u.info;  /* base register for call */</span>
<span class="lineNum">     979 </span><span class="lineCov">       8005 :   if (hasmultret(args.k))</span>
<span class="lineNum">     980 </span><span class="lineCov">         82 :     nparams = LUA_MULTRET;  /* open call */</span>
<span class="lineNum">     981 </span>            :   else {
<span class="lineNum">     982 </span><span class="lineCov">       7923 :     if (args.k != VVOID)</span>
<span class="lineNum">     983 </span><span class="lineCov">       7567 :       luaK_exp2nextreg(fs, &amp;args);  /* close last argument */</span>
<span class="lineNum">     984 </span><span class="lineCov">       7923 :     nparams = fs-&gt;freereg - (base+1);</span>
<span class="lineNum">     985 </span>            :   }
<span class="lineNum">     986 </span><span class="lineCov">       8005 :   init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));</span>
<span class="lineNum">     987 </span><span class="lineCov">       8005 :   luaK_fixline(fs, line);</span>
<span class="lineNum">     988 </span><span class="lineCov">       8005 :   fs-&gt;freereg = base+1;  /* call remove function and arguments and leaves</span>
<span class="lineNum">     989 </span>            :                             (unless changed) one result */
<span class="lineNum">     990 </span><span class="lineCov">       8005 : }</span>
<span class="lineNum">     991 </span>            : 
<span class="lineNum">     992 </span>            : 
<span class="lineNum">     993 </span>            : 
<span class="lineNum">     994 </span>            : 
<span class="lineNum">     995 </span>            : /*
<span class="lineNum">     996 </span>            : ** {======================================================================
<span class="lineNum">     997 </span>            : ** Expression parsing
<span class="lineNum">     998 </span>            : ** =======================================================================
<span class="lineNum">     999 </span>            : */
<span class="lineNum">    1000 </span>            : 
<span class="lineNum">    1001 </span>            : 
<span class="lineNum">    1002 </span><span class="lineCov">      18591 : static void primaryexp (LexState *ls, expdesc *v) {</span>
<span class="lineNum">    1003 </span>            :   /* primaryexp -&gt; NAME | '(' expr ')' */
<span class="lineNum">    1004 </span><span class="lineCov">      18591 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">    1005 </span><span class="lineCov">         48 :     case '(': {</span>
<span class="lineNum">    1006 </span><span class="lineCov">         48 :       int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1007 </span><span class="lineCov">         48 :       luaX_next(ls);</span>
<span class="lineNum">    1008 </span><span class="lineCov">         48 :       expr(ls, v);</span>
<span class="lineNum">    1009 </span><span class="lineCov">         48 :       check_match(ls, ')', '(', line);</span>
<span class="lineNum">    1010 </span><span class="lineCov">         47 :       luaK_dischargevars(ls-&gt;fs, v);</span>
<span class="lineNum">    1011 </span><span class="lineCov">         47 :       return;</span>
<span class="lineNum">    1012 </span>            :     }
<span class="lineNum">    1013 </span><span class="lineCov">      18537 :     case TK_NAME: {</span>
<span class="lineNum">    1014 </span><span class="lineCov">      18537 :       singlevar(ls, v);</span>
<span class="lineNum">    1015 </span><span class="lineCov">      18537 :       return;</span>
<span class="lineNum">    1016 </span>            :     }
<span class="lineNum">    1017 </span><span class="lineCov">          6 :     default: {</span>
<span class="lineNum">    1018 </span><span class="lineCov">          6 :       luaX_syntaxerror(ls, &quot;unexpected symbol&quot;);</span>
<span class="lineNum">    1019 </span>            :     }
<span class="lineNum">    1020 </span>            :   }
<span class="lineNum">    1021 </span>            : }
<span class="lineNum">    1022 </span>            : 
<span class="lineNum">    1023 </span>            : 
<span class="lineNum">    1024 </span><span class="lineCov">      18591 : static void suffixedexp (LexState *ls, expdesc *v) {</span>
<span class="lineNum">    1025 </span>            :   /* suffixedexp -&gt;
<span class="lineNum">    1026 </span>            :        primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
<span class="lineNum">    1027 </span><span class="lineCov">      18591 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1028 </span><span class="lineCov">      18591 :   int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1029 </span><span class="lineCov">      18591 :   primaryexp(ls, v);</span>
<span class="lineNum">    1030 </span>            :   for (;;) {
<span class="lineNum">    1031 </span><span class="lineCov">      29273 :     switch (ls-&gt;t.token) {</span>
<span class="lineNum">    1032 </span><span class="lineCov">       2039 :       case '.': {  /* fieldsel */</span>
<span class="lineNum">    1033 </span><span class="lineCov">       2039 :         fieldsel(ls, v);</span>
<span class="lineNum">    1034 </span><span class="lineCov">       2039 :         break;</span>
<span class="lineNum">    1035 </span>            :       }
<span class="lineNum">    1036 </span><span class="lineCov">        645 :       case '[': {  /* '[' exp ']' */</span>
<span class="lineNum">    1037 </span>            :         expdesc key;
<span class="lineNum">    1038 </span><span class="lineCov">        645 :         luaK_exp2anyregup(fs, v);</span>
<span class="lineNum">    1039 </span><span class="lineCov">        645 :         yindex(ls, &amp;key);</span>
<span class="lineNum">    1040 </span><span class="lineCov">        645 :         luaK_indexed(fs, v, &amp;key);</span>
<span class="lineNum">    1041 </span><span class="lineCov">        645 :         break;</span>
<span class="lineNum">    1042 </span>            :       }
<span class="lineNum">    1043 </span><span class="lineCov">        455 :       case ':': {  /* ':' NAME funcargs */</span>
<span class="lineNum">    1044 </span>            :         expdesc key;
<span class="lineNum">    1045 </span><span class="lineCov">        455 :         luaX_next(ls);</span>
<span class="lineNum">    1046 </span><span class="lineCov">        455 :         codename(ls, &amp;key);</span>
<span class="lineNum">    1047 </span><span class="lineCov">        455 :         luaK_self(fs, v, &amp;key);</span>
<span class="lineNum">    1048 </span><span class="lineCov">        455 :         funcargs(ls, v, line);</span>
<span class="lineNum">    1049 </span><span class="lineCov">        454 :         break;</span>
<span class="lineNum">    1050 </span>            :       }
<span class="lineNum">    1051 </span><span class="lineCov">       7553 :       case '(': case TK_STRING: case '{': {  /* funcargs */</span>
<span class="lineNum">    1052 </span><span class="lineCov">       7553 :         luaK_exp2nextreg(fs, v);</span>
<span class="lineNum">    1053 </span><span class="lineCov">       7553 :         funcargs(ls, v, line);</span>
<span class="lineNum">    1054 </span><span class="lineCov">       7551 :         break;</span>
<span class="lineNum">    1055 </span>            :       }
<span class="lineNum">    1056 </span><span class="lineCov">      18581 :       default: return;</span>
<span class="lineNum">    1057 </span>            :     }
<span class="lineNum">    1058 </span>            :   }
<span class="lineNum">    1059 </span>            : }
<span class="lineNum">    1060 </span>            : 
<span class="lineNum">    1061 </span>            : 
<span class="lineNum">    1062 </span><span class="lineCov">      24699 : static void simpleexp (LexState *ls, expdesc *v) {</span>
<span class="lineNum">    1063 </span>            :   /* simpleexp -&gt; FLT | INT | STRING | NIL | TRUE | FALSE | ... |
<span class="lineNum">    1064 </span>            :                   constructor | FUNCTION body | suffixedexp */
<span class="lineNum">    1065 </span><span class="lineCov">      24699 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">    1066 </span><span class="lineCov">        161 :     case TK_FLT: {</span>
<span class="lineNum">    1067 </span><span class="lineCov">        161 :       init_exp(v, VKFLT, 0);</span>
<span class="lineNum">    1068 </span><span class="lineCov">        161 :       v-&gt;u.nval = ls-&gt;t.seminfo.r;</span>
<span class="lineNum">    1069 </span><span class="lineCov">        161 :       break;</span>
<span class="lineNum">    1070 </span>            :     }
<span class="lineNum">    1071 </span><span class="lineCov">       3235 :     case TK_INT: {</span>
<span class="lineNum">    1072 </span><span class="lineCov">       3235 :       init_exp(v, VKINT, 0);</span>
<span class="lineNum">    1073 </span><span class="lineCov">       3235 :       v-&gt;u.ival = ls-&gt;t.seminfo.i;</span>
<span class="lineNum">    1074 </span><span class="lineCov">       3235 :       break;</span>
<span class="lineNum">    1075 </span>            :     }
<span class="lineNum">    1076 </span><span class="lineCov">       6631 :     case TK_STRING: {</span>
<span class="lineNum">    1077 </span><span class="lineCov">       6631 :       codestring(ls, v, ls-&gt;t.seminfo.ts);</span>
<span class="lineNum">    1078 </span><span class="lineCov">       6631 :       break;</span>
<span class="lineNum">    1079 </span>            :     }
<span class="lineNum">    1080 </span><span class="lineCov">        299 :     case TK_NIL: {</span>
<span class="lineNum">    1081 </span><span class="lineCov">        299 :       init_exp(v, VNIL, 0);</span>
<span class="lineNum">    1082 </span><span class="lineCov">        299 :       break;</span>
<span class="lineNum">    1083 </span>            :     }
<span class="lineNum">    1084 </span><span class="lineCov">        438 :     case TK_TRUE: {</span>
<span class="lineNum">    1085 </span><span class="lineCov">        438 :       init_exp(v, VTRUE, 0);</span>
<span class="lineNum">    1086 </span><span class="lineCov">        438 :       break;</span>
<span class="lineNum">    1087 </span>            :     }
<span class="lineNum">    1088 </span><span class="lineCov">        496 :     case TK_FALSE: {</span>
<span class="lineNum">    1089 </span><span class="lineCov">        496 :       init_exp(v, VFALSE, 0);</span>
<span class="lineNum">    1090 </span><span class="lineCov">        496 :       break;</span>
<span class="lineNum">    1091 </span>            :     }
<span class="lineNum">    1092 </span><span class="lineCov">         20 :     case TK_DOTS: {  /* vararg */</span>
<span class="lineNum">    1093 </span><span class="lineCov">         20 :       FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1094 </span><span class="lineCov">         20 :       check_condition(ls, fs-&gt;f-&gt;is_vararg,</span>
<span class="lineNum">    1095 </span>            :                       &quot;cannot use '...' outside a vararg function&quot;);
<span class="lineNum">    1096 </span><span class="lineCov">         19 :       init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 0, 1));</span>
<span class="lineNum">    1097 </span><span class="lineCov">         19 :       break;</span>
<span class="lineNum">    1098 </span>            :     }
<span class="lineNum">    1099 </span><span class="lineCov">        683 :     case '{': {  /* constructor */</span>
<span class="lineNum">    1100 </span><span class="lineCov">        683 :       constructor(ls, v);</span>
<span class="lineNum">    1101 </span><span class="lineCov">        682 :       return;</span>
<span class="lineNum">    1102 </span>            :     }
<span class="lineNum">    1103 </span><span class="lineCov">        563 :     case TK_FUNCTION: {</span>
<span class="lineNum">    1104 </span><span class="lineCov">        563 :       luaX_next(ls);</span>
<span class="lineNum">    1105 </span><span class="lineCov">        563 :       body(ls, v, 0, ls-&gt;linenumber);</span>
<span class="lineNum">    1106 </span><span class="lineCov">        563 :       return;</span>
<span class="lineNum">    1107 </span>            :     }
<span class="lineNum">    1108 </span><span class="lineCov">      12173 :     default: {</span>
<span class="lineNum">    1109 </span><span class="lineCov">      12173 :       suffixedexp(ls, v);</span>
<span class="lineNum">    1110 </span><span class="lineCov">      12170 :       return;</span>
<span class="lineNum">    1111 </span>            :     }
<span class="lineNum">    1112 </span>            :   }
<span class="lineNum">    1113 </span><span class="lineCov">      11279 :   luaX_next(ls);</span>
<span class="lineNum">    1114 </span>            : }
<span class="lineNum">    1115 </span>            : 
<span class="lineNum">    1116 </span>            : 
<span class="lineNum">    1117 </span><span class="lineCov">      25707 : static UnOpr getunopr (int op) {</span>
<span class="lineNum">    1118 </span><span class="lineCov">      25707 :   switch (op) {</span>
<span class="lineNum">    1119 </span><span class="lineCov">        313 :     case TK_NOT: return OPR_NOT;</span>
<span class="lineNum">    1120 </span><span class="lineCov">        167 :     case '-': return OPR_MINUS;</span>
<span class="lineNum">    1121 </span><span class="lineCov">         12 :     case '~': return OPR_BNOT;</span>
<span class="lineNum">    1122 </span><span class="lineCov">        516 :     case '#': return OPR_LEN;</span>
<span class="lineNum">    1123 </span><span class="lineCov">      24699 :     default: return OPR_NOUNOPR;</span>
<span class="lineNum">    1124 </span>            :   }
<span class="lineNum">    1125 </span>            : }
<span class="lineNum">    1126 </span>            : 
<span class="lineNum">    1127 </span>            : 
<span class="lineNum">    1128 </span><span class="lineCov">      25702 : static BinOpr getbinopr (int op) {</span>
<span class="lineNum">    1129 </span><span class="lineCov">      25702 :   switch (op) {</span>
<span class="lineNum">    1130 </span><span class="lineCov">        269 :     case '+': return OPR_ADD;</span>
<span class="lineNum">    1131 </span><span class="lineCov">        197 :     case '-': return OPR_SUB;</span>
<span class="lineNum">    1132 </span><span class="lineCov">         78 :     case '*': return OPR_MUL;</span>
<span class="lineNum">    1133 </span><span class="lineCov">         26 :     case '%': return OPR_MOD;</span>
<span class="lineNum">    1134 </span><span class="lineCov">         30 :     case '^': return OPR_POW;</span>
<span class="lineNum">    1135 </span><span class="lineCov">         48 :     case '/': return OPR_DIV;</span>
<span class="lineNum">    1136 </span><span class="lineCov">         29 :     case TK_IDIV: return OPR_IDIV;</span>
<span class="lineNum">    1137 </span><span class="lineCov">         20 :     case '&amp;': return OPR_BAND;</span>
<span class="lineNum">    1138 </span><span class="lineCov">         20 :     case '|': return OPR_BOR;</span>
<span class="lineNum">    1139 </span><span class="lineCov">         20 :     case '~': return OPR_BXOR;</span>
<span class="lineNum">    1140 </span><span class="lineCov">         20 :     case TK_SHL: return OPR_SHL;</span>
<span class="lineNum">    1141 </span><span class="lineCov">         20 :     case TK_SHR: return OPR_SHR;</span>
<span class="lineNum">    1142 </span><span class="lineCov">       1827 :     case TK_CONCAT: return OPR_CONCAT;</span>
<span class="lineNum">    1143 </span><span class="lineCov">        237 :     case TK_NE: return OPR_NE;</span>
<span class="lineNum">    1144 </span><span class="lineCov">        558 :     case TK_EQ: return OPR_EQ;</span>
<span class="lineNum">    1145 </span><span class="lineCov">         44 :     case '&lt;': return OPR_LT;</span>
<span class="lineNum">    1146 </span><span class="lineCov">         39 :     case TK_LE: return OPR_LE;</span>
<span class="lineNum">    1147 </span><span class="lineCov">         36 :     case '&gt;': return OPR_GT;</span>
<span class="lineNum">    1148 </span><span class="lineCov">        142 :     case TK_GE: return OPR_GE;</span>
<span class="lineNum">    1149 </span><span class="lineCov">        102 :     case TK_AND: return OPR_AND;</span>
<span class="lineNum">    1150 </span><span class="lineCov">        186 :     case TK_OR: return OPR_OR;</span>
<span class="lineNum">    1151 </span><span class="lineCov">      21754 :     default: return OPR_NOBINOPR;</span>
<span class="lineNum">    1152 </span>            :   }
<span class="lineNum">    1153 </span>            : }
<span class="lineNum">    1154 </span>            : 
<span class="lineNum">    1155 </span>            : 
<span class="lineNum">    1156 </span>            : /*
<span class="lineNum">    1157 </span>            : ** Priority table for binary operators.
<span class="lineNum">    1158 </span>            : */
<span class="lineNum">    1159 </span>            : static const struct {
<span class="lineNum">    1160 </span>            :   lu_byte left;  /* left priority for each binary operator */
<span class="lineNum">    1161 </span>            :   lu_byte right; /* right priority */
<span class="lineNum">    1162 </span>            : } priority[] = {  /* ORDER OPR */
<span class="lineNum">    1163 </span>            :    {10, 10}, {10, 10},           /* '+' '-' */
<span class="lineNum">    1164 </span>            :    {11, 11}, {11, 11},           /* '*' '%' */
<span class="lineNum">    1165 </span>            :    {14, 13},                  /* '^' (right associative) */
<span class="lineNum">    1166 </span>            :    {11, 11}, {11, 11},           /* '/' '//' */
<span class="lineNum">    1167 </span>            :    {6, 6}, {4, 4}, {5, 5},   /* '&amp;' '|' '~' */
<span class="lineNum">    1168 </span>            :    {7, 7}, {7, 7},           /* '&lt;&lt;' '&gt;&gt;' */
<span class="lineNum">    1169 </span>            :    {9, 8},                   /* '..' (right associative) */
<span class="lineNum">    1170 </span>            :    {3, 3}, {3, 3}, {3, 3},   /* ==, &lt;, &lt;= */
<span class="lineNum">    1171 </span>            :    {3, 3}, {3, 3}, {3, 3},   /* ~=, &gt;, &gt;= */
<span class="lineNum">    1172 </span>            :    {2, 2}, {1, 1}            /* and, or */
<span class="lineNum">    1173 </span>            : };
<span class="lineNum">    1174 </span>            : 
<span class="lineNum">    1175 </span>            : #define UNARY_PRIORITY  12  /* priority for unary operators */
<span class="lineNum">    1176 </span>            : 
<span class="lineNum">    1177 </span>            : 
<span class="lineNum">    1178 </span>            : /*
<span class="lineNum">    1179 </span>            : ** subexpr -&gt; (simpleexp | unop subexpr) { binop subexpr }
<span class="lineNum">    1180 </span>            : ** where 'binop' is any binary operator with a priority higher than 'limit'
<span class="lineNum">    1181 </span>            : */
<span class="lineNum">    1182 </span><span class="lineCov">      25707 : static BinOpr subexpr (LexState *ls, expdesc *v, int limit) {</span>
<span class="lineNum">    1183 </span>            :   BinOpr op;
<span class="lineNum">    1184 </span>            :   UnOpr uop;
<span class="lineNum">    1185 </span><span class="lineCov">      25707 :   enterlevel(ls);</span>
<span class="lineNum">    1186 </span><span class="lineCov">      25707 :   uop = getunopr(ls-&gt;t.token);</span>
<span class="lineNum">    1187 </span><span class="lineCov">      25707 :   if (uop != OPR_NOUNOPR) {  /* prefix (unary) operator? */</span>
<span class="lineNum">    1188 </span><span class="lineCov">       1008 :     int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1189 </span><span class="lineCov">       1008 :     luaX_next(ls);  /* skip operator */</span>
<span class="lineNum">    1190 </span><span class="lineCov">       1008 :     subexpr(ls, v, UNARY_PRIORITY);</span>
<span class="lineNum">    1191 </span><span class="lineCov">       1008 :     luaK_prefix(ls-&gt;fs, uop, v, line);</span>
<span class="lineNum">    1192 </span>            :   }
<span class="lineNum">    1193 </span><span class="lineCov">      24699 :   else simpleexp(ls, v);</span>
<span class="lineNum">    1194 </span>            :   /* expand while operators have priorities higher than 'limit' */
<span class="lineNum">    1195 </span><span class="lineCov">      25702 :   op = getbinopr(ls-&gt;t.token);</span>
<span class="lineNum">    1196 </span><span class="lineCov">      29397 :   while (op != OPR_NOBINOPR &amp;&amp; priority[op].left &gt; limit) {</span>
<span class="lineNum">    1197 </span>            :     expdesc v2;
<span class="lineNum">    1198 </span>            :     BinOpr nextop;
<span class="lineNum">    1199 </span><span class="lineCov">       3695 :     int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1200 </span><span class="lineCov">       3695 :     luaX_next(ls);  /* skip operator */</span>
<span class="lineNum">    1201 </span><span class="lineCov">       3695 :     luaK_infix(ls-&gt;fs, op, v);</span>
<span class="lineNum">    1202 </span>            :     /* read sub-expression with higher priority */
<span class="lineNum">    1203 </span><span class="lineCov">       3695 :     nextop = subexpr(ls, &amp;v2, priority[op].right);</span>
<span class="lineNum">    1204 </span><span class="lineCov">       3695 :     luaK_posfix(ls-&gt;fs, op, v, &amp;v2, line);</span>
<span class="lineNum">    1205 </span><span class="lineCov">       3695 :     op = nextop;</span>
<span class="lineNum">    1206 </span>            :   }
<span class="lineNum">    1207 </span><span class="lineCov">      25702 :   leavelevel(ls);</span>
<span class="lineNum">    1208 </span><span class="lineCov">      25702 :   return op;  /* return first untreated operator */</span>
<span class="lineNum">    1209 </span>            : }
<span class="lineNum">    1210 </span>            : 
<span class="lineNum">    1211 </span>            : 
<span class="lineNum">    1212 </span><span class="lineCov">      21004 : static void expr (LexState *ls, expdesc *v) {</span>
<span class="lineNum">    1213 </span><span class="lineCov">      21004 :   subexpr(ls, v, 0);</span>
<span class="lineNum">    1214 </span><span class="lineCov">      20999 : }</span>
<span class="lineNum">    1215 </span>            : 
<span class="lineNum">    1216 </span>            : /* }==================================================================== */
<span class="lineNum">    1217 </span>            : 
<span class="lineNum">    1218 </span>            : 
<span class="lineNum">    1219 </span>            : 
<span class="lineNum">    1220 </span>            : /*
<span class="lineNum">    1221 </span>            : ** {======================================================================
<span class="lineNum">    1222 </span>            : ** Rules for Statements
<span class="lineNum">    1223 </span>            : ** =======================================================================
<span class="lineNum">    1224 </span>            : */
<span class="lineNum">    1225 </span>            : 
<span class="lineNum">    1226 </span>            : 
<span class="lineNum">    1227 </span><span class="lineCov">       1157 : static void block (LexState *ls) {</span>
<span class="lineNum">    1228 </span>            :   /* block -&gt; statlist */
<span class="lineNum">    1229 </span><span class="lineCov">       1157 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1230 </span>            :   BlockCnt bl;
<span class="lineNum">    1231 </span><span class="lineCov">       1157 :   enterblock(fs, &amp;bl, 0);</span>
<span class="lineNum">    1232 </span><span class="lineCov">       1157 :   statlist(ls);</span>
<span class="lineNum">    1233 </span><span class="lineCov">       1157 :   leaveblock(fs);</span>
<span class="lineNum">    1234 </span><span class="lineCov">       1157 : }</span>
<span class="lineNum">    1235 </span>            : 
<span class="lineNum">    1236 </span>            : 
<span class="lineNum">    1237 </span>            : /*
<span class="lineNum">    1238 </span>            : ** structure to chain all variables in the left-hand side of an
<span class="lineNum">    1239 </span>            : ** assignment
<span class="lineNum">    1240 </span>            : */
<span class="lineNum">    1241 </span>            : struct LHS_assign {
<span class="lineNum">    1242 </span>            :   struct LHS_assign *prev;
<span class="lineNum">    1243 </span>            :   expdesc v;  /* variable (global, local, upvalue, or indexed) */
<span class="lineNum">    1244 </span>            : };
<span class="lineNum">    1245 </span>            : 
<span class="lineNum">    1246 </span>            : 
<span class="lineNum">    1247 </span>            : /*
<span class="lineNum">    1248 </span>            : ** check whether, in an assignment to an upvalue/local variable, the
<span class="lineNum">    1249 </span>            : ** upvalue/local variable is begin used in a previous assignment to a
<span class="lineNum">    1250 </span>            : ** table. If so, save original upvalue/local value in a safe place and
<span class="lineNum">    1251 </span>            : ** use this safe copy in the previous assignment.
<span class="lineNum">    1252 </span>            : */
<span class="lineNum">    1253 </span><span class="lineCov">         89 : static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc *v) {</span>
<span class="lineNum">    1254 </span><span class="lineCov">         89 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1255 </span><span class="lineCov">         89 :   int extra = fs-&gt;freereg;  /* eventual position to save local variable */</span>
<span class="lineNum">    1256 </span><span class="lineCov">         89 :   int conflict = 0;</span>
<span class="lineNum">    1257 </span><span class="lineCov">        189 :   for (; lh; lh = lh-&gt;prev) {  /* check all previous assignments */</span>
<span class="lineNum">    1258 </span><span class="lineCov">        100 :     if (vkisindexed(lh-&gt;v.k)) {  /* assignment to table field? */</span>
<span class="lineNum">    1259 </span><span class="lineNoCov">          0 :       if (lh-&gt;v.k == VINDEXUP) {  /* is table an upvalue? */</span>
<span class="lineNum">    1260 </span><span class="lineNoCov">          0 :         if (v-&gt;k == VUPVAL &amp;&amp; lh-&gt;v.u.ind.t == v-&gt;u.var.idx) {</span>
<span class="lineNum">    1261 </span><span class="lineNoCov">          0 :           conflict = 1;  /* table is the upvalue being assigned now */</span>
<span class="lineNum">    1262 </span><span class="lineNoCov">          0 :           lh-&gt;v.k = VINDEXSTR;</span>
<span class="lineNum">    1263 </span><span class="lineNoCov">          0 :           lh-&gt;v.u.ind.t = extra;  /* assignment will use safe copy */</span>
<span class="lineNum">    1264 </span>            :         }
<span class="lineNum">    1265 </span>            :       }
<span class="lineNum">    1266 </span>            :       else {  /* table is a register */
<span class="lineNum">    1267 </span><span class="lineNoCov">          0 :         if (v-&gt;k == VLOCAL &amp;&amp; lh-&gt;v.u.ind.t == v-&gt;u.var.idx) {</span>
<span class="lineNum">    1268 </span><span class="lineNoCov">          0 :           conflict = 1;  /* table is the local being assigned now */</span>
<span class="lineNum">    1269 </span><span class="lineNoCov">          0 :           lh-&gt;v.u.ind.t = extra;  /* assignment will use safe copy */</span>
<span class="lineNum">    1270 </span>            :         }
<span class="lineNum">    1271 </span>            :         /* is index the local being assigned? */
<span class="lineNum">    1272 </span><span class="lineNoCov">          0 :         if (lh-&gt;v.k == VINDEXED &amp;&amp; v-&gt;k == VLOCAL &amp;&amp;</span>
<span class="lineNum">    1273 </span><span class="lineNoCov">          0 :             lh-&gt;v.u.ind.idx == v-&gt;u.var.idx) {</span>
<span class="lineNum">    1274 </span><span class="lineNoCov">          0 :           conflict = 1;</span>
<span class="lineNum">    1275 </span><span class="lineNoCov">          0 :           lh-&gt;v.u.ind.idx = extra;  /* previous assignment will use safe copy */</span>
<span class="lineNum">    1276 </span>            :         }
<span class="lineNum">    1277 </span>            :       }
<span class="lineNum">    1278 </span>            :     }
<span class="lineNum">    1279 </span>            :   }
<span class="lineNum">    1280 </span><span class="lineCov">         89 :   if (conflict) {</span>
<span class="lineNum">    1281 </span>            :     /* copy upvalue/local value to a temporary (in position 'extra') */
<span class="lineNum">    1282 </span><span class="lineNoCov">          0 :     OpCode op = (v-&gt;k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;</span>
<span class="lineNum">    1283 </span><span class="lineNoCov">          0 :     luaK_codeABC(fs, op, extra, v-&gt;u.var.idx, 0);</span>
<span class="lineNum">    1284 </span><span class="lineNoCov">          0 :     luaK_reserveregs(fs, 1);</span>
<span class="lineNum">    1285 </span>            :   }
<span class="lineNum">    1286 </span><span class="lineCov">         89 : }</span>
<span class="lineNum">    1287 </span>            : 
<span class="lineNum">    1288 </span>            : /*
<span class="lineNum">    1289 </span>            : ** Parse and compile a mulitple assignment. The first &quot;variable&quot;
<span class="lineNum">    1290 </span>            : ** (a 'suffixedexp') was already read by the caller.
<span class="lineNum">    1291 </span>            : **
<span class="lineNum">    1292 </span>            : ** assignment -&gt; suffixedexp restassign
<span class="lineNum">    1293 </span>            : ** restassign -&gt; ',' suffixedexp restassign | '=' explist
<span class="lineNum">    1294 </span>            : */
<span class="lineNum">    1295 </span><span class="lineCov">       1543 : static void restassign (LexState *ls, struct LHS_assign *lh, int nvars) {</span>
<span class="lineNum">    1296 </span>            :   expdesc e;
<span class="lineNum">    1297 </span><span class="lineCov">       1543 :   check_condition(ls, vkisvar(lh-&gt;v.k), &quot;syntax error&quot;);</span>
<span class="lineNum">    1298 </span><span class="lineCov">       1543 :   check_readonly(ls, &amp;lh-&gt;v);</span>
<span class="lineNum">    1299 </span><span class="lineCov">       1541 :   if (testnext(ls, ',')) {  /* restassign -&gt; ',' suffixedexp restassign */</span>
<span class="lineNum">    1300 </span>            :     struct LHS_assign nv;
<span class="lineNum">    1301 </span><span class="lineCov">         96 :     nv.prev = lh;</span>
<span class="lineNum">    1302 </span><span class="lineCov">         96 :     suffixedexp(ls, &amp;nv.v);</span>
<span class="lineNum">    1303 </span><span class="lineCov">         96 :     if (!vkisindexed(nv.v.k))</span>
<span class="lineNum">    1304 </span><span class="lineCov">         89 :       check_conflict(ls, lh, &amp;nv.v);</span>
<span class="lineNum">    1305 </span><span class="lineCov">         96 :     enterlevel(ls);  /* control recursion depth */</span>
<span class="lineNum">    1306 </span><span class="lineCov">         96 :     restassign(ls, &amp;nv, nvars+1);</span>
<span class="lineNum">    1307 </span><span class="lineCov">         96 :     leavelevel(ls);</span>
<span class="lineNum">    1308 </span>            :   }
<span class="lineNum">    1309 </span>            :   else {  /* restassign -&gt; '=' explist */
<span class="lineNum">    1310 </span>            :     int nexps;
<span class="lineNum">    1311 </span><span class="lineCov">       1445 :     checknext(ls, '=');</span>
<span class="lineNum">    1312 </span><span class="lineCov">       1431 :     nexps = explist(ls, &amp;e);</span>
<span class="lineNum">    1313 </span><span class="lineCov">       1427 :     if (nexps != nvars)</span>
<span class="lineNum">    1314 </span><span class="lineCov">         76 :       adjust_assign(ls, nvars, nexps, &amp;e);</span>
<span class="lineNum">    1315 </span>            :     else {
<span class="lineNum">    1316 </span><span class="lineCov">       1351 :       luaK_setoneret(ls-&gt;fs, &amp;e);  /* close last expression */</span>
<span class="lineNum">    1317 </span><span class="lineCov">       1351 :       luaK_storevar(ls-&gt;fs, &amp;lh-&gt;v, &amp;e);</span>
<span class="lineNum">    1318 </span><span class="lineCov">       1351 :       return;  /* avoid default */</span>
<span class="lineNum">    1319 </span>            :     }
<span class="lineNum">    1320 </span>            :   }
<span class="lineNum">    1321 </span><span class="lineCov">        172 :   init_exp(&amp;e, VNONRELOC, ls-&gt;fs-&gt;freereg-1);  /* default assignment */</span>
<span class="lineNum">    1322 </span><span class="lineCov">        172 :   luaK_storevar(ls-&gt;fs, &amp;lh-&gt;v, &amp;e);</span>
<span class="lineNum">    1323 </span>            : }
<span class="lineNum">    1324 </span>            : 
<span class="lineNum">    1325 </span>            : 
<span class="lineNum">    1326 </span><span class="lineCov">         23 : static int cond (LexState *ls) {</span>
<span class="lineNum">    1327 </span>            :   /* cond -&gt; exp */
<span class="lineNum">    1328 </span>            :   expdesc v;
<span class="lineNum">    1329 </span><span class="lineCov">         23 :   expr(ls, &amp;v);  /* read condition */</span>
<span class="lineNum">    1330 </span><span class="lineCov">         23 :   if (v.k == VNIL) v.k = VFALSE;  /* 'falses' are all equal here */</span>
<span class="lineNum">    1331 </span><span class="lineCov">         23 :   luaK_goiftrue(ls-&gt;fs, &amp;v);</span>
<span class="lineNum">    1332 </span><span class="lineCov">         23 :   return v.f;</span>
<span class="lineNum">    1333 </span>            : }
<span class="lineNum">    1334 </span>            : 
<span class="lineNum">    1335 </span>            : 
<span class="lineNum">    1336 </span><span class="lineCov">          5 : static void gotostat (LexState *ls) {</span>
<span class="lineNum">    1337 </span><span class="lineCov">          5 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1338 </span><span class="lineCov">          5 :   int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1339 </span><span class="lineCov">          5 :   TString *name = str_checkname(ls);  /* label's name */</span>
<span class="lineNum">    1340 </span><span class="lineCov">          5 :   Labeldesc *lb = findlabel(ls, name);</span>
<span class="lineNum">    1341 </span><span class="lineCov">          5 :   if (lb == NULL)  /* no label? */</span>
<span class="lineNum">    1342 </span>            :     /* forward jump; will be resolved when the label is declared */
<span class="lineNum">    1343 </span><span class="lineCov">          4 :     newgotoentry(ls, name, line, luaK_jump(fs));</span>
<span class="lineNum">    1344 </span>            :   else {  /* found a label */
<span class="lineNum">    1345 </span>            :     /* backward jump; will be resolved here */
<span class="lineNum">    1346 </span><span class="lineCov">          1 :     if (fs-&gt;nactvar &gt; lb-&gt;nactvar)  /* leaving the scope of some variable? */</span>
<span class="lineNum">    1347 </span><span class="lineNoCov">          0 :       luaK_codeABC(fs, OP_CLOSE, lb-&gt;nactvar, 0, 0);</span>
<span class="lineNum">    1348 </span>            :     /* create jump and link it to the label */
<span class="lineNum">    1349 </span><span class="lineCov">          1 :     luaK_patchlist(fs, luaK_jump(fs), lb-&gt;pc);</span>
<span class="lineNum">    1350 </span>            :   }
<span class="lineNum">    1351 </span><span class="lineCov">          5 : }</span>
<span class="lineNum">    1352 </span>            : 
<span class="lineNum">    1353 </span>            : 
<span class="lineNum">    1354 </span>            : /*
<span class="lineNum">    1355 </span>            : ** Break statement. Semantically equivalent to &quot;goto break&quot;.
<span class="lineNum">    1356 </span>            : */
<span class="lineNum">    1357 </span><span class="lineCov">          6 : static void breakstat (LexState *ls) {</span>
<span class="lineNum">    1358 </span><span class="lineCov">          6 :   int line = ls-&gt;linenumber;</span>
<span class="lineNum">    1359 </span><span class="lineCov">          6 :   luaX_next(ls);  /* skip break */</span>
<span class="lineNum">    1360 </span><span class="lineCov">          6 :   newgotoentry(ls, luaS_newliteral(ls-&gt;L, &quot;break&quot;), line, luaK_jump(ls-&gt;fs));</span>
<span class="lineNum">    1361 </span><span class="lineCov">          6 : }</span>
<span class="lineNum">    1362 </span>            : 
<span class="lineNum">    1363 </span>            : 
<span class="lineNum">    1364 </span>            : /*
<span class="lineNum">    1365 </span>            : ** Check whether there is already a label with the given 'name'.
<span class="lineNum">    1366 </span>            : */
<span class="lineNum">    1367 </span><span class="lineCov">          8 : static void checkrepeated (LexState *ls, TString *name) {</span>
<span class="lineNum">    1368 </span><span class="lineCov">          8 :   Labeldesc *lb = findlabel(ls, name);</span>
<span class="lineNum">    1369 </span><span class="lineCov">          8 :   if (unlikely(lb != NULL)) {  /* already defined? */</span>
<span class="lineNum">    1370 </span><span class="lineCov">          1 :     const char *msg = &quot;label '%s' already defined on line %d&quot;;</span>
<span class="lineNum">    1371 </span><span class="lineCov">          1 :     msg = luaO_pushfstring(ls-&gt;L, msg, getstr(name), lb-&gt;line);</span>
<span class="lineNum">    1372 </span><span class="lineCov">          1 :     luaK_semerror(ls, msg);  /* error */</span>
<span class="lineNum">    1373 </span>            :   }
<span class="lineNum">    1374 </span><span class="lineCov">          7 : }</span>
<span class="lineNum">    1375 </span>            : 
<span class="lineNum">    1376 </span>            : 
<span class="lineNum">    1377 </span><span class="lineCov">          8 : static void labelstat (LexState *ls, TString *name, int line) {</span>
<span class="lineNum">    1378 </span>            :   /* label -&gt; '::' NAME '::' */
<span class="lineNum">    1379 </span><span class="lineCov">          8 :   checknext(ls, TK_DBCOLON);  /* skip double colon */</span>
<span class="lineNum">    1380 </span><span class="lineCov">          9 :   while (ls-&gt;t.token == ';' || ls-&gt;t.token == TK_DBCOLON)</span>
<span class="lineNum">    1381 </span><span class="lineCov">          1 :     statement(ls);  /* skip other no-op statements */</span>
<span class="lineNum">    1382 </span><span class="lineCov">          8 :   checkrepeated(ls, name);  /* check for repeated labels */</span>
<span class="lineNum">    1383 </span><span class="lineCov">          7 :   createlabel(ls, name, line, block_follow(ls, 0));</span>
<span class="lineNum">    1384 </span><span class="lineCov">          6 : }</span>
<span class="lineNum">    1385 </span>            : 
<span class="lineNum">    1386 </span>            : 
<span class="lineNum">    1387 </span><span class="lineCov">         20 : static void whilestat (LexState *ls, int line) {</span>
<span class="lineNum">    1388 </span>            :   /* whilestat -&gt; WHILE cond DO block END */
<span class="lineNum">    1389 </span><span class="lineCov">         20 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1390 </span>            :   int whileinit;
<span class="lineNum">    1391 </span>            :   int condexit;
<span class="lineNum">    1392 </span>            :   BlockCnt bl;
<span class="lineNum">    1393 </span><span class="lineCov">         20 :   luaX_next(ls);  /* skip WHILE */</span>
<span class="lineNum">    1394 </span><span class="lineCov">         20 :   whileinit = luaK_getlabel(fs);</span>
<span class="lineNum">    1395 </span><span class="lineCov">         20 :   condexit = cond(ls);</span>
<span class="lineNum">    1396 </span><span class="lineCov">         20 :   enterblock(fs, &amp;bl, 1);</span>
<span class="lineNum">    1397 </span><span class="lineCov">         20 :   checknext(ls, TK_DO);</span>
<span class="lineNum">    1398 </span><span class="lineCov">         19 :   block(ls);</span>
<span class="lineNum">    1399 </span><span class="lineCov">         19 :   luaK_jumpto(fs, whileinit);</span>
<span class="lineNum">    1400 </span><span class="lineCov">         19 :   check_match(ls, TK_END, TK_WHILE, line);</span>
<span class="lineNum">    1401 </span><span class="lineCov">         18 :   leaveblock(fs);</span>
<span class="lineNum">    1402 </span><span class="lineCov">         18 :   luaK_patchtohere(fs, condexit);  /* false conditions finish the loop */</span>
<span class="lineNum">    1403 </span><span class="lineCov">         18 : }</span>
<span class="lineNum">    1404 </span>            : 
<span class="lineNum">    1405 </span>            : 
<span class="lineNum">    1406 </span><span class="lineCov">          4 : static void repeatstat (LexState *ls, int line) {</span>
<span class="lineNum">    1407 </span>            :   /* repeatstat -&gt; REPEAT block UNTIL cond */
<span class="lineNum">    1408 </span>            :   int condexit;
<span class="lineNum">    1409 </span><span class="lineCov">          4 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1410 </span><span class="lineCov">          4 :   int repeat_init = luaK_getlabel(fs);</span>
<span class="lineNum">    1411 </span>            :   BlockCnt bl1, bl2;
<span class="lineNum">    1412 </span><span class="lineCov">          4 :   enterblock(fs, &amp;bl1, 1);  /* loop block */</span>
<span class="lineNum">    1413 </span><span class="lineCov">          4 :   enterblock(fs, &amp;bl2, 0);  /* scope block */</span>
<span class="lineNum">    1414 </span><span class="lineCov">          4 :   luaX_next(ls);  /* skip REPEAT */</span>
<span class="lineNum">    1415 </span><span class="lineCov">          4 :   statlist(ls);</span>
<span class="lineNum">    1416 </span><span class="lineCov">          4 :   check_match(ls, TK_UNTIL, TK_REPEAT, line);</span>
<span class="lineNum">    1417 </span><span class="lineCov">          3 :   condexit = cond(ls);  /* read condition (inside scope block) */</span>
<span class="lineNum">    1418 </span><span class="lineCov">          3 :   leaveblock(fs);  /* finish scope */</span>
<span class="lineNum">    1419 </span><span class="lineCov">          3 :   if (bl2.upval) {  /* upvalues? */</span>
<span class="lineNum">    1420 </span><span class="lineNoCov">          0 :     int exit = luaK_jump(fs);  /* normal exit must jump over fix */</span>
<span class="lineNum">    1421 </span><span class="lineNoCov">          0 :     luaK_patchtohere(fs, condexit);  /* repetition must close upvalues */</span>
<span class="lineNum">    1422 </span><span class="lineNoCov">          0 :     luaK_codeABC(fs, OP_CLOSE, bl2.nactvar, 0, 0);</span>
<span class="lineNum">    1423 </span><span class="lineNoCov">          0 :     condexit = luaK_jump(fs);  /* repeat after closing upvalues */</span>
<span class="lineNum">    1424 </span><span class="lineNoCov">          0 :     luaK_patchtohere(fs, exit);  /* normal exit comes to here */</span>
<span class="lineNum">    1425 </span>            :   }
<span class="lineNum">    1426 </span><span class="lineCov">          3 :   luaK_patchlist(fs, condexit, repeat_init);  /* close the loop */</span>
<span class="lineNum">    1427 </span><span class="lineCov">          3 :   leaveblock(fs);  /* finish loop */</span>
<span class="lineNum">    1428 </span><span class="lineCov">          3 : }</span>
<span class="lineNum">    1429 </span>            : 
<span class="lineNum">    1430 </span>            : 
<span class="lineNum">    1431 </span>            : /*
<span class="lineNum">    1432 </span>            : ** Read an expression and generate code to put its results in next
<span class="lineNum">    1433 </span>            : ** stack slot.
<span class="lineNum">    1434 </span>            : **
<span class="lineNum">    1435 </span>            : */
<span class="lineNum">    1436 </span><span class="lineCov">        577 : static void exp1 (LexState *ls) {</span>
<span class="lineNum">    1437 </span>            :   expdesc e;
<span class="lineNum">    1438 </span><span class="lineCov">        577 :   expr(ls, &amp;e);</span>
<span class="lineNum">    1439 </span><span class="lineCov">        577 :   luaK_exp2nextreg(ls-&gt;fs, &amp;e);</span>
<span class="lineNum">    1440 </span>            :   lua_assert(e.k == VNONRELOC);
<span class="lineNum">    1441 </span><span class="lineCov">        577 : }</span>
<span class="lineNum">    1442 </span>            : 
<span class="lineNum">    1443 </span>            : 
<span class="lineNum">    1444 </span>            : /*
<span class="lineNum">    1445 </span>            : ** Fix for instruction at position 'pc' to jump to 'dest'.
<span class="lineNum">    1446 </span>            : ** (Jump addresses are relative in Lua). 'back' true means
<span class="lineNum">    1447 </span>            : ** a back jump.
<span class="lineNum">    1448 </span>            : */
<span class="lineNum">    1449 </span><span class="lineCov">        642 : static void fixforjump (FuncState *fs, int pc, int dest, int back) {</span>
<span class="lineNum">    1450 </span><span class="lineCov">        642 :   Instruction *jmp = &amp;fs-&gt;f-&gt;code[pc];</span>
<span class="lineNum">    1451 </span><span class="lineCov">        642 :   int offset = dest - (pc + 1);</span>
<span class="lineNum">    1452 </span><span class="lineCov">        642 :   if (back)</span>
<span class="lineNum">    1453 </span><span class="lineCov">        321 :     offset = -offset;</span>
<span class="lineNum">    1454 </span><span class="lineCov">        642 :   if (unlikely(offset &gt; MAXARG_Bx))</span>
<span class="lineNum">    1455 </span><span class="lineNoCov">          0 :     luaX_syntaxerror(fs-&gt;ls, &quot;control structure too long&quot;);</span>
<span class="lineNum">    1456 </span><span class="lineCov">        642 :   SETARG_Bx(*jmp, offset);</span>
<span class="lineNum">    1457 </span><span class="lineCov">        642 : }</span>
<span class="lineNum">    1458 </span>            : 
<span class="lineNum">    1459 </span>            : 
<span class="lineNum">    1460 </span>            : /*
<span class="lineNum">    1461 </span>            : ** Generate code for a 'for' loop.
<span class="lineNum">    1462 </span>            : */
<span class="lineNum">    1463 </span><span class="lineCov">        322 : static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {</span>
<span class="lineNum">    1464 </span>            :   /* forbody -&gt; DO block */
<span class="lineNum">    1465 </span>            :   static OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};
<span class="lineNum">    1466 </span>            :   static OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};
<span class="lineNum">    1467 </span>            :   BlockCnt bl;
<span class="lineNum">    1468 </span><span class="lineCov">        322 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1469 </span>            :   int prep, endfor;
<span class="lineNum">    1470 </span><span class="lineCov">        322 :   checknext(ls, TK_DO);</span>
<span class="lineNum">    1471 </span><span class="lineCov">        321 :   prep = luaK_codeABx(fs, forprep[isgen], base, 0);</span>
<span class="lineNum">    1472 </span><span class="lineCov">        321 :   enterblock(fs, &amp;bl, 0);  /* scope for declared variables */</span>
<span class="lineNum">    1473 </span><span class="lineCov">        321 :   adjustlocalvars(ls, nvars);</span>
<span class="lineNum">    1474 </span><span class="lineCov">        321 :   luaK_reserveregs(fs, nvars);</span>
<span class="lineNum">    1475 </span><span class="lineCov">        321 :   block(ls);</span>
<span class="lineNum">    1476 </span><span class="lineCov">        321 :   leaveblock(fs);  /* end of scope for declared variables */</span>
<span class="lineNum">    1477 </span><span class="lineCov">        321 :   fixforjump(fs, prep, luaK_getlabel(fs), 0);</span>
<span class="lineNum">    1478 </span><span class="lineCov">        321 :   if (isgen) {  /* generic for? */</span>
<span class="lineNum">    1479 </span><span class="lineCov">         43 :     luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);</span>
<span class="lineNum">    1480 </span><span class="lineCov">         43 :     luaK_fixline(fs, line);</span>
<span class="lineNum">    1481 </span><span class="lineCov">         43 :     base += 2;  /* base for 'OP_TFORLOOP' (skips function and state) */</span>
<span class="lineNum">    1482 </span>            :   }
<span class="lineNum">    1483 </span><span class="lineCov">        321 :   endfor = luaK_codeABx(fs, forloop[isgen], base, 0);</span>
<span class="lineNum">    1484 </span><span class="lineCov">        321 :   fixforjump(fs, endfor, prep + 1, 1);</span>
<span class="lineNum">    1485 </span><span class="lineCov">        321 :   luaK_fixline(fs, line);</span>
<span class="lineNum">    1486 </span><span class="lineCov">        321 : }</span>
<span class="lineNum">    1487 </span>            : 
<span class="lineNum">    1488 </span>            : 
<span class="lineNum">    1489 </span><span class="lineCov">        279 : static void fornum (LexState *ls, TString *varname, int line) {</span>
<span class="lineNum">    1490 </span>            :   /* fornum -&gt; NAME = exp,exp[,exp] forbody */
<span class="lineNum">    1491 </span><span class="lineCov">        279 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1492 </span><span class="lineCov">        279 :   int base = fs-&gt;freereg;</span>
<span class="lineNum">    1493 </span><span class="lineCov">        279 :   new_localvarliteral(ls, &quot;(for index)&quot;);</span>
<span class="lineNum">    1494 </span><span class="lineCov">        279 :   new_localvarliteral(ls, &quot;(for limit)&quot;);</span>
<span class="lineNum">    1495 </span><span class="lineCov">        279 :   new_localvarliteral(ls, &quot;(for step)&quot;);</span>
<span class="lineNum">    1496 </span><span class="lineCov">        279 :   new_localvar(ls, varname);</span>
<span class="lineNum">    1497 </span><span class="lineCov">        279 :   checknext(ls, '=');</span>
<span class="lineNum">    1498 </span><span class="lineCov">        279 :   exp1(ls);  /* initial value */</span>
<span class="lineNum">    1499 </span><span class="lineCov">        279 :   checknext(ls, ',');</span>
<span class="lineNum">    1500 </span><span class="lineCov">        279 :   exp1(ls);  /* limit */</span>
<span class="lineNum">    1501 </span><span class="lineCov">        279 :   if (testnext(ls, ','))</span>
<span class="lineNum">    1502 </span><span class="lineCov">         14 :     exp1(ls);  /* optional step */</span>
<span class="lineNum">    1503 </span>            :   else {  /* default step = 1 */
<span class="lineNum">    1504 </span><span class="lineCov">        265 :     luaK_int(fs, fs-&gt;freereg, 1);</span>
<span class="lineNum">    1505 </span><span class="lineCov">        265 :     luaK_reserveregs(fs, 1);</span>
<span class="lineNum">    1506 </span>            :   }
<span class="lineNum">    1507 </span><span class="lineCov">        279 :   adjustlocalvars(ls, 3);  /* control variables */</span>
<span class="lineNum">    1508 </span><span class="lineCov">        279 :   forbody(ls, base, line, 1, 0);</span>
<span class="lineNum">    1509 </span><span class="lineCov">        278 : }</span>
<span class="lineNum">    1510 </span>            : 
<span class="lineNum">    1511 </span>            : 
<span class="lineNum">    1512 </span><span class="lineCov">         43 : static void forlist (LexState *ls, TString *indexname) {</span>
<span class="lineNum">    1513 </span>            :   /* forlist -&gt; NAME {,NAME} IN explist forbody */
<span class="lineNum">    1514 </span><span class="lineCov">         43 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1515 </span>            :   expdesc e;
<span class="lineNum">    1516 </span><span class="lineCov">         43 :   int nvars = 5;  /* gen, state, control, toclose, 'indexname' */</span>
<span class="lineNum">    1517 </span>            :   int line;
<span class="lineNum">    1518 </span><span class="lineCov">         43 :   int base = fs-&gt;freereg;</span>
<span class="lineNum">    1519 </span>            :   /* create control variables */
<span class="lineNum">    1520 </span><span class="lineCov">         43 :   new_localvarliteral(ls, &quot;(for generator)&quot;);</span>
<span class="lineNum">    1521 </span><span class="lineCov">         43 :   new_localvarliteral(ls, &quot;(for state)&quot;);</span>
<span class="lineNum">    1522 </span><span class="lineCov">         43 :   markupval(fs, fs-&gt;nactvar);  /* state may create an upvalue */</span>
<span class="lineNum">    1523 </span><span class="lineCov">         43 :   new_localvarliteral(ls, &quot;(for control)&quot;);</span>
<span class="lineNum">    1524 </span><span class="lineCov">         43 :   new_localvarliteral(ls, &quot;(for toclose)&quot;);</span>
<span class="lineNum">    1525 </span>            :   /* create declared variables */
<span class="lineNum">    1526 </span><span class="lineCov">         43 :   new_localvar(ls, indexname);</span>
<span class="lineNum">    1527 </span><span class="lineCov">         66 :   while (testnext(ls, ',')) {</span>
<span class="lineNum">    1528 </span><span class="lineCov">         23 :     new_localvar(ls, str_checkname(ls));</span>
<span class="lineNum">    1529 </span><span class="lineCov">         23 :     nvars++;</span>
<span class="lineNum">    1530 </span>            :   }
<span class="lineNum">    1531 </span><span class="lineCov">         43 :   checknext(ls, TK_IN);</span>
<span class="lineNum">    1532 </span><span class="lineCov">         43 :   line = ls-&gt;linenumber;</span>
<span class="lineNum">    1533 </span><span class="lineCov">         43 :   adjust_assign(ls, 4, explist(ls, &amp;e), &amp;e);</span>
<span class="lineNum">    1534 </span><span class="lineCov">         43 :   adjustlocalvars(ls, 4);  /* control variables */</span>
<span class="lineNum">    1535 </span><span class="lineCov">         43 :   luaK_checkstack(fs, 3);  /* extra space to call generator */</span>
<span class="lineNum">    1536 </span><span class="lineCov">         43 :   forbody(ls, base, line, nvars - 4, 1);</span>
<span class="lineNum">    1537 </span><span class="lineCov">         43 : }</span>
<span class="lineNum">    1538 </span>            : 
<span class="lineNum">    1539 </span>            : 
<span class="lineNum">    1540 </span><span class="lineCov">        323 : static void forstat (LexState *ls, int line) {</span>
<span class="lineNum">    1541 </span>            :   /* forstat -&gt; FOR (fornum | forlist) END */
<span class="lineNum">    1542 </span><span class="lineCov">        323 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1543 </span>            :   TString *varname;
<span class="lineNum">    1544 </span>            :   BlockCnt bl;
<span class="lineNum">    1545 </span><span class="lineCov">        323 :   enterblock(fs, &amp;bl, 1);  /* scope for loop and control variables */</span>
<span class="lineNum">    1546 </span><span class="lineCov">        323 :   luaX_next(ls);  /* skip 'for' */</span>
<span class="lineNum">    1547 </span><span class="lineCov">        323 :   varname = str_checkname(ls);  /* first variable name */</span>
<span class="lineNum">    1548 </span><span class="lineCov">        323 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">    1549 </span><span class="lineCov">        279 :     case '=': fornum(ls, varname, line); break;</span>
<span class="lineNum">    1550 </span><span class="lineCov">         43 :     case ',': case TK_IN: forlist(ls, varname); break;</span>
<span class="lineNum">    1551 </span><span class="lineCov">          1 :     default: luaX_syntaxerror(ls, &quot;'=' or 'in' expected&quot;);</span>
<span class="lineNum">    1552 </span>            :   }
<span class="lineNum">    1553 </span><span class="lineCov">        321 :   check_match(ls, TK_END, TK_FOR, line);</span>
<span class="lineNum">    1554 </span><span class="lineCov">        320 :   leaveblock(fs);  /* loop scope ('break' jumps to this point) */</span>
<span class="lineNum">    1555 </span><span class="lineCov">        320 : }</span>
<span class="lineNum">    1556 </span>            : 
<span class="lineNum">    1557 </span>            : 
<span class="lineNum">    1558 </span>            : /*
<span class="lineNum">    1559 </span>            : ** Check whether next instruction is a single jump (a 'break', a 'goto'
<span class="lineNum">    1560 </span>            : ** to a forward label, or a 'goto' to a backward label with no variable
<span class="lineNum">    1561 </span>            : ** to close). If so, set the name of the 'label' it is jumping to
<span class="lineNum">    1562 </span>            : ** (&quot;break&quot; for a 'break') or to where it is jumping to ('target') and
<span class="lineNum">    1563 </span>            : ** return true. If not a single jump, leave input unchanged, to be
<span class="lineNum">    1564 </span>            : ** handled as a regular statement.
<span class="lineNum">    1565 </span>            : */
<span class="lineNum">    1566 </span><span class="lineCov">       1214 : static int issinglejump (LexState *ls, TString **label, int *target) {</span>
<span class="lineNum">    1567 </span><span class="lineCov">       1214 :   if (testnext(ls, TK_BREAK)) {  /* a break? */</span>
<span class="lineNum">    1568 </span><span class="lineCov">          8 :     *label = luaS_newliteral(ls-&gt;L, &quot;break&quot;);</span>
<span class="lineNum">    1569 </span><span class="lineCov">          8 :     return 1;</span>
<span class="lineNum">    1570 </span>            :   }
<span class="lineNum">    1571 </span><span class="lineCov">       1206 :   else if (ls-&gt;t.token != TK_GOTO || luaX_lookahead(ls) != TK_NAME)</span>
<span class="lineNum">    1572 </span><span class="lineCov">       1206 :     return 0;  /* not a valid goto */</span>
<span class="lineNum">    1573 </span>            :   else {
<span class="lineNum">    1574 </span><span class="lineNoCov">          0 :     TString *lname = ls-&gt;lookahead.seminfo.ts;  /* label's id */</span>
<span class="lineNum">    1575 </span><span class="lineNoCov">          0 :     Labeldesc *lb = findlabel(ls, lname);</span>
<span class="lineNum">    1576 </span><span class="lineNoCov">          0 :     if (lb) {  /* a backward jump? */</span>
<span class="lineNum">    1577 </span><span class="lineNoCov">          0 :       if (ls-&gt;fs-&gt;nactvar &gt; lb-&gt;nactvar)  /* needs to close variables? */</span>
<span class="lineNum">    1578 </span><span class="lineNoCov">          0 :         return 0;  /* not a single jump; cannot optimize */</span>
<span class="lineNum">    1579 </span><span class="lineNoCov">          0 :       *target = lb-&gt;pc;</span>
<span class="lineNum">    1580 </span>            :     }
<span class="lineNum">    1581 </span>            :     else  /* jump forward */
<span class="lineNum">    1582 </span><span class="lineNoCov">          0 :       *label = lname;</span>
<span class="lineNum">    1583 </span><span class="lineNoCov">          0 :     luaX_next(ls);  /* skip goto */</span>
<span class="lineNum">    1584 </span><span class="lineNoCov">          0 :     luaX_next(ls);  /* skip name */</span>
<span class="lineNum">    1585 </span><span class="lineNoCov">          0 :     return 1;</span>
<span class="lineNum">    1586 </span>            :   }
<span class="lineNum">    1587 </span>            : }
<span class="lineNum">    1588 </span>            : 
<span class="lineNum">    1589 </span>            : 
<span class="lineNum">    1590 </span><span class="lineCov">       1215 : static void test_then_block (LexState *ls, int *escapelist) {</span>
<span class="lineNum">    1591 </span>            :   /* test_then_block -&gt; [IF | ELSEIF] cond THEN block */
<span class="lineNum">    1592 </span>            :   BlockCnt bl;
<span class="lineNum">    1593 </span>            :   int line;
<span class="lineNum">    1594 </span><span class="lineCov">       1215 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1595 </span><span class="lineCov">       1215 :   TString *jlb = NULL;</span>
<span class="lineNum">    1596 </span><span class="lineCov">       1215 :   int target = NO_JUMP;</span>
<span class="lineNum">    1597 </span>            :   expdesc v;
<span class="lineNum">    1598 </span>            :   int jf;  /* instruction to skip 'then' code (if condition is false) */
<span class="lineNum">    1599 </span><span class="lineCov">       1215 :   luaX_next(ls);  /* skip IF or ELSEIF */</span>
<span class="lineNum">    1600 </span><span class="lineCov">       1215 :   expr(ls, &amp;v);  /* read condition */</span>
<span class="lineNum">    1601 </span><span class="lineCov">       1215 :   checknext(ls, TK_THEN);</span>
<span class="lineNum">    1602 </span><span class="lineCov">       1214 :   line = ls-&gt;linenumber;</span>
<span class="lineNum">    1603 </span><span class="lineCov">       1214 :   if (issinglejump(ls, &amp;jlb, &amp;target)) {  /* 'if x then goto' ? */</span>
<span class="lineNum">    1604 </span><span class="lineCov">          8 :     luaK_goiffalse(ls-&gt;fs, &amp;v);  /* will jump to label if condition is true */</span>
<span class="lineNum">    1605 </span><span class="lineCov">          8 :     enterblock(fs, &amp;bl, 0);  /* must enter block before 'goto' */</span>
<span class="lineNum">    1606 </span><span class="lineCov">          8 :     if (jlb != NULL)  /* forward jump? */</span>
<span class="lineNum">    1607 </span><span class="lineCov">          8 :       newgotoentry(ls, jlb, line, v.t);  /* will be resolved later */</span>
<span class="lineNum">    1608 </span>            :     else  /* backward jump */
<span class="lineNum">    1609 </span><span class="lineNoCov">          0 :       luaK_patchlist(fs, v.t, target);  /* jump directly to 'target' */</span>
<span class="lineNum">    1610 </span><span class="lineCov">          8 :     while (testnext(ls, ';')) {}  /* skip semicolons */</span>
<span class="lineNum">    1611 </span><span class="lineCov">          8 :     if (block_follow(ls, 0)) {  /* jump is the entire block? */</span>
<span class="lineNum">    1612 </span><span class="lineCov">          7 :       leaveblock(fs);</span>
<span class="lineNum">    1613 </span><span class="lineCov">          7 :       return;  /* and that is it */</span>
<span class="lineNum">    1614 </span>            :     }
<span class="lineNum">    1615 </span>            :     else  /* must skip over 'then' part if condition is false */
<span class="lineNum">    1616 </span><span class="lineCov">          1 :       jf = luaK_jump(fs);</span>
<span class="lineNum">    1617 </span>            :   }
<span class="lineNum">    1618 </span>            :   else {  /* regular case (not a jump) */
<span class="lineNum">    1619 </span><span class="lineCov">       1206 :     luaK_goiftrue(ls-&gt;fs, &amp;v);  /* skip over block if condition is false */</span>
<span class="lineNum">    1620 </span><span class="lineCov">       1206 :     enterblock(fs, &amp;bl, 0);</span>
<span class="lineNum">    1621 </span><span class="lineCov">       1206 :     jf = v.f;</span>
<span class="lineNum">    1622 </span>            :   }
<span class="lineNum">    1623 </span><span class="lineCov">       1207 :   statlist(ls);  /* 'then' part */</span>
<span class="lineNum">    1624 </span><span class="lineCov">       1207 :   leaveblock(fs);</span>
<span class="lineNum">    1625 </span><span class="lineCov">       1207 :   if (ls-&gt;t.token == TK_ELSE ||</span>
<span class="lineNum">    1626 </span><span class="lineCov">        691 :       ls-&gt;t.token == TK_ELSEIF)  /* followed by 'else'/'elseif'? */</span>
<span class="lineNum">    1627 </span><span class="lineCov">        548 :     luaK_concat(fs, escapelist, luaK_jump(fs));  /* must jump over it */</span>
<span class="lineNum">    1628 </span><span class="lineCov">       1207 :   luaK_patchtohere(fs, jf);</span>
<span class="lineNum">    1629 </span>            : }
<span class="lineNum">    1630 </span>            : 
<span class="lineNum">    1631 </span>            : 
<span class="lineNum">    1632 </span><span class="lineCov">       1183 : static void ifstat (LexState *ls, int line) {</span>
<span class="lineNum">    1633 </span>            :   /* ifstat -&gt; IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
<span class="lineNum">    1634 </span><span class="lineCov">       1183 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1635 </span><span class="lineCov">       1183 :   int escapelist = NO_JUMP;  /* exit list for finished parts */</span>
<span class="lineNum">    1636 </span><span class="lineCov">       1183 :   test_then_block(ls, &amp;escapelist);  /* IF cond THEN block */</span>
<span class="lineNum">    1637 </span><span class="lineCov">       1214 :   while (ls-&gt;t.token == TK_ELSEIF)</span>
<span class="lineNum">    1638 </span><span class="lineCov">         32 :     test_then_block(ls, &amp;escapelist);  /* ELSEIF cond THEN block */</span>
<span class="lineNum">    1639 </span><span class="lineCov">       1182 :   if (testnext(ls, TK_ELSE))</span>
<span class="lineNum">    1640 </span><span class="lineCov">        516 :     block(ls);  /* 'else' part */</span>
<span class="lineNum">    1641 </span><span class="lineCov">       1182 :   check_match(ls, TK_END, TK_IF, line);</span>
<span class="lineNum">    1642 </span><span class="lineCov">       1181 :   luaK_patchtohere(fs, escapelist);  /* patch escape list to 'if' end */</span>
<span class="lineNum">    1643 </span><span class="lineCov">       1181 : }</span>
<span class="lineNum">    1644 </span>            : 
<span class="lineNum">    1645 </span>            : 
<span class="lineNum">    1646 </span><span class="lineCov">         95 : static void localfunc (LexState *ls) {</span>
<span class="lineNum">    1647 </span>            :   expdesc b;
<span class="lineNum">    1648 </span><span class="lineCov">         95 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1649 </span><span class="lineCov">         95 :   new_localvar(ls, str_checkname(ls));  /* new local variable */</span>
<span class="lineNum">    1650 </span><span class="lineCov">         95 :   adjustlocalvars(ls, 1);  /* enter its scope */</span>
<span class="lineNum">    1651 </span><span class="lineCov">         95 :   body(ls, &amp;b, 0, ls-&gt;linenumber);  /* function created in next register */</span>
<span class="lineNum">    1652 </span>            :   /* debug information will only see the variable after this point! */
<span class="lineNum">    1653 </span><span class="lineCov">         95 :   getlocvar(fs, b.u.info)-&gt;startpc = fs-&gt;pc;</span>
<span class="lineNum">    1654 </span><span class="lineCov">         95 : }</span>
<span class="lineNum">    1655 </span>            : 
<span class="lineNum">    1656 </span>            : 
<span class="lineNum">    1657 </span><span class="lineCov">       1881 : static void commonlocalstat (LexState *ls) {</span>
<span class="lineNum">    1658 </span>            :   /* stat -&gt; LOCAL NAME {',' NAME} ['=' explist] */
<span class="lineNum">    1659 </span><span class="lineCov">       1881 :   int nvars = 0;</span>
<span class="lineNum">    1660 </span>            :   int nexps;
<span class="lineNum">    1661 </span>            :   expdesc e;
<span class="lineNum">    1662 </span>            :   do {
<span class="lineNum">    1663 </span><span class="lineCov">       2090 :     new_localvar(ls, str_checkname(ls));</span>
<span class="lineNum">    1664 </span><span class="lineCov">       2090 :     nvars++;</span>
<span class="lineNum">    1665 </span><span class="lineCov">       2090 :   } while (testnext(ls, ','));</span>
<span class="lineNum">    1666 </span><span class="lineCov">       1881 :   if (testnext(ls, '='))</span>
<span class="lineNum">    1667 </span><span class="lineCov">       1822 :     nexps = explist(ls, &amp;e);</span>
<span class="lineNum">    1668 </span>            :   else {
<span class="lineNum">    1669 </span><span class="lineCov">         59 :     e.k = VVOID;</span>
<span class="lineNum">    1670 </span><span class="lineCov">         59 :     nexps = 0;</span>
<span class="lineNum">    1671 </span>            :   }
<span class="lineNum">    1672 </span><span class="lineCov">       1881 :   adjust_assign(ls, nvars, nexps, &amp;e);</span>
<span class="lineNum">    1673 </span><span class="lineCov">       1881 :   adjustlocalvars(ls, nvars);</span>
<span class="lineNum">    1674 </span><span class="lineCov">       1881 : }</span>
<span class="lineNum">    1675 </span>            : 
<span class="lineNum">    1676 </span>            : 
<span class="lineNum">    1677 </span><span class="lineCov">          3 : static void tocloselocalstat (LexState *ls, Vardesc *var) {</span>
<span class="lineNum">    1678 </span><span class="lineCov">          3 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1679 </span><span class="lineCov">          3 :   var-&gt;ro = 1;  /* to-be-closed variables are always read-only */</span>
<span class="lineNum">    1680 </span><span class="lineCov">          3 :   markupval(fs, fs-&gt;nactvar);</span>
<span class="lineNum">    1681 </span><span class="lineCov">          3 :   fs-&gt;bl-&gt;insidetbc = 1;  /* in the scope of a to-be-closed variable */</span>
<span class="lineNum">    1682 </span><span class="lineCov">          3 :   luaK_codeABC(fs, OP_TBC, fs-&gt;nactvar - 1, 0, 0);</span>
<span class="lineNum">    1683 </span><span class="lineCov">          3 : }</span>
<span class="lineNum">    1684 </span>            : 
<span class="lineNum">    1685 </span>            : 
<span class="lineNum">    1686 </span><span class="lineCov">          5 : static void attriblocalstat (LexState *ls) {</span>
<span class="lineNum">    1687 </span>            :   Vardesc *var;
<span class="lineNum">    1688 </span><span class="lineCov">          5 :   TString *attr = str_checkname(ls);</span>
<span class="lineNum">    1689 </span><span class="lineCov">          5 :   testnext(ls, '&gt;');</span>
<span class="lineNum">    1690 </span><span class="lineCov">          5 :   var = new_localvar(ls, str_checkname(ls));</span>
<span class="lineNum">    1691 </span><span class="lineCov">          5 :   checknext(ls, '=');</span>
<span class="lineNum">    1692 </span><span class="lineCov">          5 :   exp1(ls);</span>
<span class="lineNum">    1693 </span><span class="lineCov">          5 :   adjustlocalvars(ls, 1);</span>
<span class="lineNum">    1694 </span><span class="lineCov">          5 :   if (strcmp(getstr(attr), &quot;const&quot;) == 0)</span>
<span class="lineNum">    1695 </span><span class="lineCov">          1 :     var-&gt;ro = 1;  /* set variable as read-only */</span>
<span class="lineNum">    1696 </span><span class="lineCov">          4 :   else if (strcmp(getstr(attr), &quot;toclose&quot;) == 0)</span>
<span class="lineNum">    1697 </span><span class="lineCov">          3 :     tocloselocalstat(ls, var);</span>
<span class="lineNum">    1698 </span>            :   else
<span class="lineNum">    1699 </span><span class="lineCov">          1 :     luaK_semerror(ls,</span>
<span class="lineNum">    1700 </span><span class="lineCov">          1 :       luaO_pushfstring(ls-&gt;L, &quot;unknown attribute '%s'&quot;, getstr(attr)));</span>
<span class="lineNum">    1701 </span><span class="lineCov">          4 : }</span>
<span class="lineNum">    1702 </span>            : 
<span class="lineNum">    1703 </span>            : 
<span class="lineNum">    1704 </span><span class="lineCov">       1886 : static void localstat (LexState *ls) {</span>
<span class="lineNum">    1705 </span>            :   /* stat -&gt; LOCAL NAME {',' NAME} ['=' explist]
<span class="lineNum">    1706 </span>            :            | LOCAL *toclose NAME '=' exp */
<span class="lineNum">    1707 </span><span class="lineCov">       1886 :   if (testnext(ls, '&lt;'))</span>
<span class="lineNum">    1708 </span><span class="lineCov">          5 :     attriblocalstat(ls);</span>
<span class="lineNum">    1709 </span>            :   else
<span class="lineNum">    1710 </span><span class="lineCov">       1881 :     commonlocalstat(ls);</span>
<span class="lineNum">    1711 </span><span class="lineCov">       1885 : }</span>
<span class="lineNum">    1712 </span>            : 
<span class="lineNum">    1713 </span>            : 
<span class="lineNum">    1714 </span><span class="lineCov">        904 : static int funcname (LexState *ls, expdesc *v) {</span>
<span class="lineNum">    1715 </span>            :   /* funcname -&gt; NAME {fieldsel} [':' NAME] */
<span class="lineNum">    1716 </span><span class="lineCov">        904 :   int ismethod = 0;</span>
<span class="lineNum">    1717 </span><span class="lineCov">        904 :   singlevar(ls, v);</span>
<span class="lineNum">    1718 </span><span class="lineCov">        941 :   while (ls-&gt;t.token == '.')</span>
<span class="lineNum">    1719 </span><span class="lineCov">         37 :     fieldsel(ls, v);</span>
<span class="lineNum">    1720 </span><span class="lineCov">        904 :   if (ls-&gt;t.token == ':') {</span>
<span class="lineNum">    1721 </span><span class="lineCov">         20 :     ismethod = 1;</span>
<span class="lineNum">    1722 </span><span class="lineCov">         20 :     fieldsel(ls, v);</span>
<span class="lineNum">    1723 </span>            :   }
<span class="lineNum">    1724 </span><span class="lineCov">        904 :   return ismethod;</span>
<span class="lineNum">    1725 </span>            : }
<span class="lineNum">    1726 </span>            : 
<span class="lineNum">    1727 </span>            : 
<span class="lineNum">    1728 </span><span class="lineCov">        904 : static void funcstat (LexState *ls, int line) {</span>
<span class="lineNum">    1729 </span>            :   /* funcstat -&gt; FUNCTION funcname body */
<span class="lineNum">    1730 </span>            :   int ismethod;
<span class="lineNum">    1731 </span>            :   expdesc v, b;
<span class="lineNum">    1732 </span><span class="lineCov">        904 :   luaX_next(ls);  /* skip FUNCTION */</span>
<span class="lineNum">    1733 </span><span class="lineCov">        904 :   ismethod = funcname(ls, &amp;v);</span>
<span class="lineNum">    1734 </span><span class="lineCov">        904 :   body(ls, &amp;b, ismethod, line);</span>
<span class="lineNum">    1735 </span><span class="lineCov">        900 :   luaK_storevar(ls-&gt;fs, &amp;v, &amp;b);</span>
<span class="lineNum">    1736 </span><span class="lineCov">        900 :   luaK_fixline(ls-&gt;fs, line);  /* definition &quot;happens&quot; in the first line */</span>
<span class="lineNum">    1737 </span><span class="lineCov">        900 : }</span>
<span class="lineNum">    1738 </span>            : 
<span class="lineNum">    1739 </span>            : 
<span class="lineNum">    1740 </span><span class="lineCov">       6322 : static void exprstat (LexState *ls) {</span>
<span class="lineNum">    1741 </span>            :   /* stat -&gt; func | assignment */
<span class="lineNum">    1742 </span><span class="lineCov">       6322 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1743 </span>            :   struct LHS_assign v;
<span class="lineNum">    1744 </span><span class="lineCov">       6322 :   suffixedexp(ls, &amp;v.v);</span>
<span class="lineNum">    1745 </span><span class="lineCov">       6315 :   if (ls-&gt;t.token == '=' || ls-&gt;t.token == ',') { /* stat -&gt; assignment ? */</span>
<span class="lineNum">    1746 </span><span class="lineCov">       1447 :     v.prev = NULL;</span>
<span class="lineNum">    1747 </span><span class="lineCov">       1447 :     restassign(ls, &amp;v, 1);</span>
<span class="lineNum">    1748 </span>            :   }
<span class="lineNum">    1749 </span>            :   else {  /* stat -&gt; func */
<span class="lineNum">    1750 </span><span class="lineCov">       4868 :     Instruction *inst = &amp;getinstruction(fs, &amp;v.v);</span>
<span class="lineNum">    1751 </span><span class="lineCov">       4868 :     check_condition(ls, v.v.k == VCALL, &quot;syntax error&quot;);</span>
<span class="lineNum">    1752 </span><span class="lineCov">       4868 :     SETARG_C(*inst, 1);  /* call statement uses no results */</span>
<span class="lineNum">    1753 </span>            :   }
<span class="lineNum">    1754 </span><span class="lineCov">       6295 : }</span>
<span class="lineNum">    1755 </span>            : 
<span class="lineNum">    1756 </span>            : 
<span class="lineNum">    1757 </span><span class="lineCov">        992 : static void retstat (LexState *ls) {</span>
<span class="lineNum">    1758 </span>            :   /* stat -&gt; RETURN [explist] [';'] */
<span class="lineNum">    1759 </span><span class="lineCov">        992 :   FuncState *fs = ls-&gt;fs;</span>
<span class="lineNum">    1760 </span>            :   expdesc e;
<span class="lineNum">    1761 </span>            :   int nret;  /* number of values being returned */
<span class="lineNum">    1762 </span><span class="lineCov">        992 :   int first = fs-&gt;nactvar;  /* first slot to be returned */</span>
<span class="lineNum">    1763 </span><span class="lineCov">        992 :   if (block_follow(ls, 1) || ls-&gt;t.token == ';')</span>
<span class="lineNum">    1764 </span><span class="lineCov">         91 :     nret = 0;  /* return no values */</span>
<span class="lineNum">    1765 </span>            :   else {
<span class="lineNum">    1766 </span><span class="lineCov">        901 :     nret = explist(ls, &amp;e);  /* optional return values */</span>
<span class="lineNum">    1767 </span><span class="lineCov">        901 :     if (hasmultret(e.k)) {</span>
<span class="lineNum">    1768 </span><span class="lineCov">        193 :       luaK_setmultret(fs, &amp;e);</span>
<span class="lineNum">    1769 </span><span class="lineCov">        193 :       if (e.k == VCALL &amp;&amp; nret == 1 &amp;&amp; !fs-&gt;bl-&gt;insidetbc) {  /* tail call? */</span>
<span class="lineNum">    1770 </span><span class="lineCov">        192 :         SET_OPCODE(getinstruction(fs,&amp;e), OP_TAILCALL);</span>
<span class="lineNum">    1771 </span>            :         lua_assert(GETARG_A(getinstruction(fs,&amp;e)) == fs-&gt;nactvar);
<span class="lineNum">    1772 </span>            :       }
<span class="lineNum">    1773 </span><span class="lineCov">        193 :       nret = LUA_MULTRET;  /* return all values */</span>
<span class="lineNum">    1774 </span>            :     }
<span class="lineNum">    1775 </span>            :     else {
<span class="lineNum">    1776 </span><span class="lineCov">        708 :       if (nret == 1)  /* only one single value? */</span>
<span class="lineNum">    1777 </span><span class="lineCov">        690 :         first = luaK_exp2anyreg(fs, &amp;e);  /* can use original slot */</span>
<span class="lineNum">    1778 </span>            :       else {  /* values must go to the top of the stack */
<span class="lineNum">    1779 </span><span class="lineCov">         18 :         luaK_exp2nextreg(fs, &amp;e);</span>
<span class="lineNum">    1780 </span>            :         lua_assert(nret == fs-&gt;freereg - first);
<span class="lineNum">    1781 </span>            :       }
<span class="lineNum">    1782 </span>            :     }
<span class="lineNum">    1783 </span>            :   }
<span class="lineNum">    1784 </span><span class="lineCov">        992 :   luaK_ret(fs, first, nret);</span>
<span class="lineNum">    1785 </span><span class="lineCov">        992 :   testnext(ls, ';');  /* skip optional semicolon */</span>
<span class="lineNum">    1786 </span><span class="lineCov">        992 : }</span>
<span class="lineNum">    1787 </span>            : 
<span class="lineNum">    1788 </span>            : 
<span class="lineNum">    1789 </span><span class="lineCov">      12161 : static void statement (LexState *ls) {</span>
<span class="lineNum">    1790 </span><span class="lineCov">      12161 :   int line = ls-&gt;linenumber;  /* may be needed for error messages */</span>
<span class="lineNum">    1791 </span><span class="lineCov">      12161 :   enterlevel(ls);</span>
<span class="lineNum">    1792 </span><span class="lineCov">      12161 :   switch (ls-&gt;t.token) {</span>
<span class="lineNum">    1793 </span><span class="lineCov">        112 :     case ';': {  /* stat -&gt; ';' (empty statement) */</span>
<span class="lineNum">    1794 </span><span class="lineCov">        112 :       luaX_next(ls);  /* skip ';' */</span>
<span class="lineNum">    1795 </span><span class="lineCov">        112 :       break;</span>
<span class="lineNum">    1796 </span>            :     }
<span class="lineNum">    1797 </span><span class="lineCov">       1183 :     case TK_IF: {  /* stat -&gt; ifstat */</span>
<span class="lineNum">    1798 </span><span class="lineCov">       1183 :       ifstat(ls, line);</span>
<span class="lineNum">    1799 </span><span class="lineCov">       1181 :       break;</span>
<span class="lineNum">    1800 </span>            :     }
<span class="lineNum">    1801 </span><span class="lineCov">         20 :     case TK_WHILE: {  /* stat -&gt; whilestat */</span>
<span class="lineNum">    1802 </span><span class="lineCov">         20 :       whilestat(ls, line);</span>
<span class="lineNum">    1803 </span><span class="lineCov">         18 :       break;</span>
<span class="lineNum">    1804 </span>            :     }
<span class="lineNum">    1805 </span><span class="lineCov">        301 :     case TK_DO: {  /* stat -&gt; DO block END */</span>
<span class="lineNum">    1806 </span><span class="lineCov">        301 :       luaX_next(ls);  /* skip DO */</span>
<span class="lineNum">    1807 </span><span class="lineCov">        301 :       block(ls);</span>
<span class="lineNum">    1808 </span><span class="lineCov">        301 :       check_match(ls, TK_END, TK_DO, line);</span>
<span class="lineNum">    1809 </span><span class="lineCov">        300 :       break;</span>
<span class="lineNum">    1810 </span>            :     }
<span class="lineNum">    1811 </span><span class="lineCov">        323 :     case TK_FOR: {  /* stat -&gt; forstat */</span>
<span class="lineNum">    1812 </span><span class="lineCov">        323 :       forstat(ls, line);</span>
<span class="lineNum">    1813 </span><span class="lineCov">        320 :       break;</span>
<span class="lineNum">    1814 </span>            :     }
<span class="lineNum">    1815 </span><span class="lineCov">          4 :     case TK_REPEAT: {  /* stat -&gt; repeatstat */</span>
<span class="lineNum">    1816 </span><span class="lineCov">          4 :       repeatstat(ls, line);</span>
<span class="lineNum">    1817 </span><span class="lineCov">          3 :       break;</span>
<span class="lineNum">    1818 </span>            :     }
<span class="lineNum">    1819 </span><span class="lineCov">        904 :     case TK_FUNCTION: {  /* stat -&gt; funcstat */</span>
<span class="lineNum">    1820 </span><span class="lineCov">        904 :       funcstat(ls, line);</span>
<span class="lineNum">    1821 </span><span class="lineCov">        900 :       break;</span>
<span class="lineNum">    1822 </span>            :     }
<span class="lineNum">    1823 </span><span class="lineCov">       1981 :     case TK_LOCAL: {  /* stat -&gt; localstat */</span>
<span class="lineNum">    1824 </span><span class="lineCov">       1981 :       luaX_next(ls);  /* skip LOCAL */</span>
<span class="lineNum">    1825 </span><span class="lineCov">       1981 :       if (testnext(ls, TK_FUNCTION))  /* local function? */</span>
<span class="lineNum">    1826 </span><span class="lineCov">         95 :         localfunc(ls);</span>
<span class="lineNum">    1827 </span>            :       else
<span class="lineNum">    1828 </span><span class="lineCov">       1886 :         localstat(ls);</span>
<span class="lineNum">    1829 </span><span class="lineCov">       1980 :       break;</span>
<span class="lineNum">    1830 </span>            :     }
<span class="lineNum">    1831 </span><span class="lineCov">          8 :     case TK_DBCOLON: {  /* stat -&gt; label */</span>
<span class="lineNum">    1832 </span><span class="lineCov">          8 :       luaX_next(ls);  /* skip double colon */</span>
<span class="lineNum">    1833 </span><span class="lineCov">          8 :       labelstat(ls, str_checkname(ls), line);</span>
<span class="lineNum">    1834 </span><span class="lineCov">          6 :       break;</span>
<span class="lineNum">    1835 </span>            :     }
<span class="lineNum">    1836 </span><span class="lineCov">        992 :     case TK_RETURN: {  /* stat -&gt; retstat */</span>
<span class="lineNum">    1837 </span><span class="lineCov">        992 :       luaX_next(ls);  /* skip RETURN */</span>
<span class="lineNum">    1838 </span><span class="lineCov">        992 :       retstat(ls);</span>
<span class="lineNum">    1839 </span><span class="lineCov">        992 :       break;</span>
<span class="lineNum">    1840 </span>            :     }
<span class="lineNum">    1841 </span><span class="lineCov">          6 :     case TK_BREAK: {  /* stat -&gt; breakstat */</span>
<span class="lineNum">    1842 </span><span class="lineCov">          6 :       breakstat(ls);</span>
<span class="lineNum">    1843 </span><span class="lineCov">          6 :       break;</span>
<span class="lineNum">    1844 </span>            :     }
<span class="lineNum">    1845 </span><span class="lineCov">          5 :     case TK_GOTO: {  /* stat -&gt; 'goto' NAME */</span>
<span class="lineNum">    1846 </span><span class="lineCov">          5 :       luaX_next(ls);  /* skip 'goto' */</span>
<span class="lineNum">    1847 </span><span class="lineCov">          5 :       gotostat(ls);</span>
<span class="lineNum">    1848 </span><span class="lineCov">          5 :       break;</span>
<span class="lineNum">    1849 </span>            :     }
<span class="lineNum">    1850 </span><span class="lineCov">       6322 :     default: {  /* stat -&gt; func | assignment */</span>
<span class="lineNum">    1851 </span><span class="lineCov">       6322 :       exprstat(ls);</span>
<span class="lineNum">    1852 </span><span class="lineCov">       6295 :       break;</span>
<span class="lineNum">    1853 </span>            :     }
<span class="lineNum">    1854 </span>            :   }
<span class="lineNum">    1855 </span>            :   lua_assert(ls-&gt;fs-&gt;f-&gt;maxstacksize &gt;= ls-&gt;fs-&gt;freereg &amp;&amp;
<span class="lineNum">    1856 </span>            :              ls-&gt;fs-&gt;freereg &gt;= ls-&gt;fs-&gt;nactvar);
<span class="lineNum">    1857 </span><span class="lineCov">      12118 :   ls-&gt;fs-&gt;freereg = ls-&gt;fs-&gt;nactvar;  /* free registers */</span>
<span class="lineNum">    1858 </span><span class="lineCov">      12118 :   leavelevel(ls);</span>
<span class="lineNum">    1859 </span><span class="lineCov">      12118 : }</span>
<span class="lineNum">    1860 </span>            : 
<span class="lineNum">    1861 </span>            : /* }====================================================================== */
<span class="lineNum">    1862 </span>            : 
<span class="lineNum">    1863 </span>            : 
<span class="lineNum">    1864 </span>            : /*
<span class="lineNum">    1865 </span>            : ** compiles the main function, which is a regular vararg function with an
<span class="lineNum">    1866 </span>            : ** upvalue named LUA_ENV
<span class="lineNum">    1867 </span>            : */
<span class="lineNum">    1868 </span><span class="lineCov">        513 : static void mainfunc (LexState *ls, FuncState *fs) {</span>
<span class="lineNum">    1869 </span>            :   BlockCnt bl;
<span class="lineNum">    1870 </span>            :   expdesc v;
<span class="lineNum">    1871 </span><span class="lineCov">        513 :   open_func(ls, fs, &amp;bl);</span>
<span class="lineNum">    1872 </span><span class="lineCov">        513 :   setvararg(fs, 0);  /* main function is always declared vararg */</span>
<span class="lineNum">    1873 </span><span class="lineCov">        513 :   init_var(&amp;v, VLOCAL, 0);  /* create and... */</span>
<span class="lineNum">    1874 </span><span class="lineCov">        513 :   newupvalue(fs, ls-&gt;envn, &amp;v);  /* ...set environment upvalue */</span>
<span class="lineNum">    1875 </span><span class="lineCov">        513 :   luaX_next(ls);  /* read first token */</span>
<span class="lineNum">    1876 </span><span class="lineCov">        512 :   statlist(ls);  /* parse main body */</span>
<span class="lineNum">    1877 </span><span class="lineCov">        470 :   check(ls, TK_EOS);</span>
<span class="lineNum">    1878 </span><span class="lineCov">        470 :   close_func(ls);</span>
<span class="lineNum">    1879 </span><span class="lineCov">        469 : }</span>
<span class="lineNum">    1880 </span>            : 
<span class="lineNum">    1881 </span>            : 
<span class="lineNum">    1882 </span><span class="lineCov">        513 : LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,</span>
<span class="lineNum">    1883 </span>            :                        Dyndata *dyd, const char *name, int firstchar) {
<span class="lineNum">    1884 </span>            :   LexState lexstate;
<span class="lineNum">    1885 </span>            :   FuncState funcstate;
<span class="lineNum">    1886 </span><span class="lineCov">        513 :   LClosure *cl = luaF_newLclosure(L, 1);  /* create main closure */</span>
<span class="lineNum">    1887 </span><span class="lineCov">        513 :   setclLvalue2s(L, L-&gt;top, cl);  /* anchor it (to avoid being collected) */</span>
<span class="lineNum">    1888 </span><span class="lineCov">        513 :   luaD_inctop(L);</span>
<span class="lineNum">    1889 </span><span class="lineCov">        513 :   lexstate.h = luaH_new(L);  /* create table for scanner */</span>
<span class="lineNum">    1890 </span><span class="lineCov">        513 :   sethvalue2s(L, L-&gt;top, lexstate.h);  /* anchor it */</span>
<span class="lineNum">    1891 </span><span class="lineCov">        513 :   luaD_inctop(L);</span>
<span class="lineNum">    1892 </span><span class="lineCov">        513 :   funcstate.f = cl-&gt;p = luaF_newproto(L);</span>
<span class="lineNum">    1893 </span><span class="lineCov">        513 :   funcstate.f-&gt;source = luaS_new(L, name);  /* create and anchor TString */</span>
<span class="lineNum">    1894 </span><span class="lineCov">        513 :   luaC_objbarrier(L, funcstate.f, funcstate.f-&gt;source);</span>
<span class="lineNum">    1895 </span><span class="lineCov">        513 :   lexstate.buff = buff;</span>
<span class="lineNum">    1896 </span><span class="lineCov">        513 :   lexstate.dyd = dyd;</span>
<span class="lineNum">    1897 </span><span class="lineCov">        513 :   dyd-&gt;actvar.n = dyd-&gt;gt.n = dyd-&gt;label.n = 0;</span>
<span class="lineNum">    1898 </span><span class="lineCov">        513 :   luaX_setinput(L, &amp;lexstate, z, funcstate.f-&gt;source, firstchar);</span>
<span class="lineNum">    1899 </span><span class="lineCov">        513 :   mainfunc(&amp;lexstate, &amp;funcstate);</span>
<span class="lineNum">    1900 </span>            :   lua_assert(!funcstate.prev &amp;&amp; funcstate.nups == 1 &amp;&amp; !lexstate.fs);
<span class="lineNum">    1901 </span>            :   /* all scopes should be correctly finished */
<span class="lineNum">    1902 </span>            :   lua_assert(dyd-&gt;actvar.n == 0 &amp;&amp; dyd-&gt;gt.n == 0 &amp;&amp; dyd-&gt;label.n == 0);
<span class="lineNum">    1903 </span><span class="lineCov">        469 :   L-&gt;top--;  /* remove scanner's table */</span>
<span class="lineNum">    1904 </span><span class="lineCov">        469 :   return cl;  /* closure is on the stack, too */</span>
<span class="lineNum">    1905 </span>            : }
<span class="lineNum">    1906 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
